Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2514413imm; Mon, 24 Sep 2018 05:45:34 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdav3bgkoeQD0CwNjLdd0vgms3YbUu3n1fWcU+1zJDkhGcSn5RnZms7Ycdsr/ikHTxWcdqCN X-Received: by 2002:a62:5882:: with SMTP id m124-v6mr10257858pfb.249.1537793134256; Mon, 24 Sep 2018 05:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793134; cv=none; d=google.com; s=arc-20160816; b=hApKwLlnqNsKYXbcP/8jUhf4uRY0qxOwdsBWWe5VUY7HMzNJVbPAJ5Httv12J9DdxE MNn++LU1Ir6otzZJYGW7FLEfrLRa+FKLvFrj0/lfY17ftc5kgGTDVxbugKvD/iFGkvDm meYbxvddQi8E000cqxEIicSdUJOG/3ZmJ671+H8ewK/QyKtVbqteq2SMpqJfKgl0R+46 MdIpHRi3IEhVjYcqoFQZNfJdTmriwx9dImNv0jZfvIK6ayX3/88Y3xjx9mqzjLEanV/N fbeR0coeIbkz6NsxRyDd+NzCwIEPj0xG3Nx0Ukg6GNk35++gX8LJHIYfACsWrm85golg +IsQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=C+3AR0XU+RqwCUiU8dRXa2EzombPI0WrasAy8trxzlw=; b=xsOsnFq+oipnvacFBuzqr5LQMSGRoMcqZj3EJJlq1J+iHsUWhsZZ3j1mwCYgTiqlQF y7AdtEOPLFnJtpZZWqg7v7CaKpfWuI9ejj0kIPxj+onTPnYqGzJ/h1u0joj/OepN+CJk nWW5U4xzyTgZshDUjo4IzI8loNHTE7Fj7GwH1LTRdyWpE3HpKvA/UNmCGTcMWaFjrA6b 6fATpxrGKEFsyK0bWQCOl3dFt76jFGDZwxRr0HK8N7a5xVVeFYatY/ZS8UcO5u3sx+0F 7MCDktp6Ipfl/5oYDtX6W6FdPxVzlYxZEaKzmtC1fB0LLgid4/Um0QLelLWDwxyX61QC YGBQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u69-v6si32281119pgd.547.2018.09.24.05.45.18; Mon, 24 Sep 2018 05:45:34 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389125AbeIXSqN (ORCPT + 99 others); Mon, 24 Sep 2018 14:46:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59568 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387512AbeIXSqN (ORCPT ); Mon, 24 Sep 2018 14:46:13 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 281BC1099; Mon, 24 Sep 2018 12:44:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "H. Nikolaus Schaller" , Christ van Willegen , Haojian Zhuang , Jacopo Mondi , Paul Cercueil , Sean Wang , Tony Lindgren , Andy Shevchenko , Linus Walleij , Sasha Levin Subject: [PATCH 4.18 164/235] pinctrl: pinmux: Return selector to the pinctrl driver Date: Mon, 24 Sep 2018 13:52:30 +0200 Message-Id: <20180924113121.469295005@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tony Lindgren [ Upstream commit f913cfce4ee49a3382a9ff95696f49a46e56e974 ] We must return the selector from pinmux_generic_add_function() so pin controller device drivers can remove the right group if needed for deferred probe for example. And we now must make sure that a proper name is passed so we can use it to check if the entry already exists. Note that fixes are also needed for the pin controller drivers to use the selector value. Fixes: a76edc89b100 ("pinctrl: core: Add generic pinctrl functions for managing groups") Reported-by: H. Nikolaus Schaller Cc: Christ van Willegen Cc: Haojian Zhuang Cc: Jacopo Mondi Cc: Paul Cercueil Cc: Sean Wang Signed-off-by: Tony Lindgren Tested-By: H. Nikolaus Schaller Reviewed-by: Andy Shevchenko Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/pinmux.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -308,7 +308,6 @@ static int pinmux_func_name_to_selector( selector++; } - dev_err(pctldev->dev, "function '%s' not supported\n", function); return -EINVAL; } @@ -775,6 +774,16 @@ int pinmux_generic_add_function(struct p void *data) { struct function_desc *function; + int selector; + + if (!name) + return -EINVAL; + + selector = pinmux_func_name_to_selector(pctldev, name); + if (selector >= 0) + return selector; + + selector = pctldev->num_functions; function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL); if (!function) @@ -785,12 +794,11 @@ int pinmux_generic_add_function(struct p function->num_group_names = num_groups; function->data = data; - radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions, - function); + radix_tree_insert(&pctldev->pin_function_tree, selector, function); pctldev->num_functions++; - return 0; + return selector; } EXPORT_SYMBOL_GPL(pinmux_generic_add_function);