Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2914668pxk; Mon, 28 Sep 2020 03:44:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9BSeRBfxeKubrkLvAw1AdAnsNyALbgjZIPLc/P9T9ny9XyW+3WmDStHZWMutCAX8svstA X-Received: by 2002:a17:906:c2d2:: with SMTP id ch18mr1040675ejb.79.1601289876003; Mon, 28 Sep 2020 03:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601289875; cv=none; d=google.com; s=arc-20160816; b=yi9gJzR+ZeB4P+80PJtPRj4QrkmpAJ4vmQTcKUNrcUp6lon0qWOjOw+5W7iwEnT39M epuJeZwT6rHp+pfDIwobGQBYwRI238Jk6mqh9/s68dfgcD1NDVoNZbYk1Mc3duek6RDa 1lfo4xSwPSlyBZIAy4w6RGYxdeqfh9O7xSimXdDNIypHqwfumFWFcgjd2OwKXCZza5/I y829V/30GB0X6qgKUUTfVE0bQA4lzZm9QU8tRVHOzNaptakfbogdvxpeLSm/UQEyapfl BH0dU/ASEJI25vQFj4iH9NPyTN+YIwvsyV/oOmucuG7itN+FN3HgX3cxfvGIBxAw3XOa d+eA== 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=DQ7hkqDUYwnD8RfHS91XVOH/KCrgmiVGe4aMxrHKxDFSLz4WRdxghoTpJscq5knky4 eFMCDHnS4GjHW1lSa7ZxM5BXI5ZNu7s2bZqJITas3iPqcaAc9GA67GczqEltt0oJaSJi bVY4JvrUDRT5jJpd1KQlZ21/tngSr4N4XWiGIYYc5ui4bgBzr0kpsbSCCV0j4g2a4I35 7f/b99dKl3FEPIbCGjBCC1Q7UdMN/TWSF0ENy1e49kTJSgYu1qOQIoDtdp++HB3C/0DB mhBokcL8rCAHQgvsKGu7S77y+NW8ntAMdpAtz6N0Ibn6J6UQHQ7IKE5gtY6s6QAT9qQB HYZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=M3VrScx8; 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 df7si335047edb.271.2020.09.28.03.44.13; Mon, 28 Sep 2020 03:44: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=M3VrScx8; 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 S1726729AbgI1Km3 (ORCPT + 99 others); Mon, 28 Sep 2020 06:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgI1KmJ (ORCPT ); Mon, 28 Sep 2020 06:42:09 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF7CC0613CF for ; Mon, 28 Sep 2020 03:42:09 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id q9so600829wmj.2 for ; Mon, 28 Sep 2020 03:42:09 -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=M3VrScx83cIf9TdOKfJkxcCgoTVUURV9fTusoQNJllZ20fwAhw3fNXK4nS/dMeO5Kt UChDVYnj1tvBAYpAby1GSsojzjdMQPXJFfLuxQvlvMgHrPm+OsNHB0Lm3aIdeLEdLohG 5LEZxvesQ3CgzaXepH2auWfMCGsI/YT0Dz3RewkJ6CiWBiXSl6pm5hyjj4XpGewnZw9n mkh+RLTVuhDswiB5ZI+UbeCxV7Rx7h/5SogblQf93ngEg1g7mek7jY5HqZQtS9gJVLqk eo6K4TosxmroAKtjKWfEQVlnwvA6KFnfgOevU3RLvKvdrOvDdMIXJ6cuLUY6Oxdyc1vj wyJg== 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=pFeAZuF8+hl4kIw9sw8UzuqHfjrnyO6mKf4jABPGpbnO36LXRa5MN7J2zzcrddNFYx hDPT6/gAWM22jJJ8hDiIEvY+fiiBVGzkdpnrUz6iedUa+SWC26Y3u2at6Zs0Wxiq03eM 7Qb033YErWxZeY4U+V3+HDRhR5PWXnXswFHhfC8oDfdKR98DH8TyE5MffxwRqoyHIO8T +KtuO3ppIoXB+6nEjKd+oit5CEH8OaUEMkPLvRjy1gDR7QjESUMbyLq2FPIm4HG1LH9O X9h0mhHBgzd0ShqvcK7XZ1GNqBrF+b9S4pJhzr3l5c3kd6Sd29xg6LvKnL34RzJt9Enn OkxQ== X-Gm-Message-State: AOAM532vMQiyk3yjPNVvM58JXwf+0XSrj8OA+z9w4JY5ae9M3snTJxuG h6ZNaUxIAqg5049c2WB7oINPoQ== X-Received: by 2002:a7b:c1d3:: with SMTP id a19mr930864wmj.19.1601289727965; Mon, 28 Sep 2020 03:42:07 -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 f14sm939258wrt.53.2020.09.28.03.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 03:42:07 -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 v2 7/9] gpio: mockup: pass the chip label as device property Date: Mon, 28 Sep 2020 12:41:53 +0200 Message-Id: <20200928104155.7385-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200928104155.7385-1-brgl@bgdev.pl> References: <20200928104155.7385-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