Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp239980pxk; Thu, 24 Sep 2020 04:40:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYeNSk+FhwFSxxpr+zZGxGL7k9Kde4HS2l6tNMfFft+vJVj2vWUD3DNWSx1bXdPoPqksNB X-Received: by 2002:aa7:c3d4:: with SMTP id l20mr524481edr.263.1600947635081; Thu, 24 Sep 2020 04:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600947635; cv=none; d=google.com; s=arc-20160816; b=k1AlE+yELxkG0ZYMst/VxfTHV0zPTuBryYhbYnJlKFiw+oKSjsNEoYx4uqGHtVr/tC 5tdG0CHIt2ARZaMEZidzWUHupOx9Z0mktRKP90RjGH1LeVgvFj8xY2MkyD538Eb9WmNG 2WpmgfeVh6HkZowDZG+TOqpXykLYSpELudwUSJZz3vurICWZe+ahzqp7TkB28QcGz1ye PSPrEMlkAOHi1vEPBNdW+3EHObLmClY39ZJMav2E7qbnBvwN3py7r3T27/g8vCWVoAP+ F6n+iAQ8OCbEiJn5oiNUvbBagKCUbFdqx21KRTWZfJjBbRTveEw1IBg2R3D5Yg67ZwCd GTsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yQHFpzhsra7eF21NOHukB6Qo7UOtUhx3yAmCZtWq61g=; b=O8vyB1JZBd576VyySJhJdczDi7pH6w9ADQyS8NwiJeUo38PjtdCjC9soH7kxBTrIiA I061uFAn9h3+PNVF3FBFakNko0u26aglmWahZGVwa+ztzvzdjSPRdJFkugEedzcJXpsA vzZgKH3mF+OPmx4OOKUIPWCBO+OPytirkE1vBO6BTc+Wdk7/8fXQCTItE8iuxEITS+sM Cux+1rXYKMvQwyh4QbJkIEpRf+/LK21fc70LQsBkJQSNv42yI6jNWJnAsAXPQPT/cUiC 73Elddw/DNP20v2A52myCScvfHlMRi7SROutfstVCL03DOBxBBKuDuKM5ZcsACshx5dH gsVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=r8b8KCmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si2020051eds.168.2020.09.24.04.40.11; Thu, 24 Sep 2020 04:40:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=r8b8KCmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727614AbgIXLjE (ORCPT + 99 others); Thu, 24 Sep 2020 07:39:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgIXLjB (ORCPT ); Thu, 24 Sep 2020 07:39:01 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15332C0613D5 for ; Thu, 24 Sep 2020 04:39:01 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id z1so3459089wrt.3 for ; Thu, 24 Sep 2020 04:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yQHFpzhsra7eF21NOHukB6Qo7UOtUhx3yAmCZtWq61g=; b=r8b8KCmCtWNNk5vpqJp3h6gV8JUjmH+9nkgQlRWIpvpCe15Egu+DmAzUrIe0+Yt96W Rij7NuiRrkA3uJ7qfOLBfpyvflwiXdGU3TxfNluhmbILQfpFYnkDj+8n7mrewCAafUvr /truc/o799wMS7i6DaMzbM1H/F4/u3uulFwzcrkGDiWOQ4LW8f53YwWnu33SoNbT4elg 4/tWzUdMAriSaZmVmogZOM9qD5aFcYT3/6SHnRktCdE0tNgZqKUbTdFyJWwo68d/8Yct oJcH35ymLp6PEkL/omBLkdbMfZ7Xxq/iD0Wr9cxKGVA/CM/JjjOMRhRpBl9LQkKJ04PJ CCNw== 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=yQHFpzhsra7eF21NOHukB6Qo7UOtUhx3yAmCZtWq61g=; b=CVHQy0DBBpmfSTajpWQsTMR/supc7WomfkjlQDQ3LTNWCbkFOpJXtnAgWIGmDe58Nb 4gQFhekGa6Vy0GPJyv19aa1/sukSNWX/hf/9fAhsiCrfA8GybVhyTGdFMZI6fKwG85q0 57tPgc4goMU1TCmV6UVXibj7vLb20lsj1jdU/x33wYF5HON+Puskz/9JVcXoan8Qh+us raR6F8coBt1lo9+saOHQkDOCFXmM4YGvi+X9IKa9Z6A+siP1WTAHe5iNfVxzr4gDdDwt 23ULFOCr1x+UsAuZM/cUh6dS3wOfzMxOcvWmkYy/peGviaLuEqb1vITuH7Slci48i421 yOfg== X-Gm-Message-State: AOAM531CDnPw/xsw+Tto30xa/BNCjw9xS4sns/rkfsHblNhwtm7TQTG8 Rf0+dOlGrLGZb3rCxg6ze8hOdw== X-Received: by 2002:adf:a4cc:: with SMTP id h12mr4555529wrb.123.1600947539806; Thu, 24 Sep 2020 04:38:59 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-68-20.w2-15.abo.wanadoo.fr. [2.15.159.20]) by smtp.gmail.com with ESMTPSA id y207sm3390133wmc.17.2020.09.24.04.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 04:38:59 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 7/9] gpio: mockup: pass the chip label as device property Date: Thu, 24 Sep 2020 13:38:40 +0200 Message-Id: <20200924113842.11670-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200924113842.11670-1-brgl@bgdev.pl> References: <20200924113842.11670-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski While we do check the "chip-name" property in probe(), we never actually use it. Let's pass the chip label to the driver using device properties as we'll want to allow users to define their own once dynamically created chips are supported. The property is renamed to "chip-label" to not cause any confusion with the actual chip name which is of the form: "gpiochipX". If the "chip-label" property is missing, let's do what most devices in drivers/gpio/ do and use dev_name(). Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index de778b52f355..5b2686f9e07d 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -429,21 +429,14 @@ static int gpio_mockup_probe(struct platform_device *pdev) if (rv) return rv; - rv = device_property_read_string(dev, "chip-name", &name); + rv = device_property_read_string(dev, "chip-label", &name); if (rv) - name = NULL; + name = dev_name(dev); chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; - if (!name) { - name = devm_kasprintf(dev, GFP_KERNEL, - "%s-%c", pdev->name, pdev->id + 'A'); - if (!name) - return -ENOMEM; - } - mutex_init(&chip->lock); gc = &chip->gc; @@ -523,6 +516,7 @@ static int __init gpio_mockup_init(void) int i, prop, num_chips, err = 0, base; struct platform_device_info pdevinfo; struct platform_device *pdev; + char chip_label[32]; u16 ngpio; if ((gpio_mockup_num_ranges < 2) || @@ -556,6 +550,11 @@ static int __init gpio_mockup_init(void) memset(&pdevinfo, 0, sizeof(pdevinfo)); prop = 0; + snprintf(chip_label, sizeof(chip_label), + "gpio-mockup-%c", i + 'A'); + properties[prop++] = PROPERTY_ENTRY_STRING("chip-label", + chip_label); + base = gpio_mockup_range_base(i); if (base >= 0) properties[prop++] = PROPERTY_ENTRY_U32("gpio-base", -- 2.26.1