Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3705875pxf; Mon, 15 Mar 2021 16:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxde2ZHVIjpayuRYusTgmD6Mni5sJ8S7/ZbjMHTIqy1khr5oEHI/4ErSj/GGilsHPdMhOp4 X-Received: by 2002:a17:906:f44:: with SMTP id h4mr25865616ejj.204.1615852118946; Mon, 15 Mar 2021 16:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615852118; cv=none; d=google.com; s=arc-20160816; b=spAxYQtuaJgoxbEhLa4E9i7IZpW5kS16dEvHRFuJg0So1L4Zalpll5krsymtIU2Hho Tm7khSsT0Xpfz/itYeYeDkhnWGvpBmK16q3Rl0Y/otBQ0/M7EDkrwYOtSM1q9Jry7Dki MfyttOlDeEAjhyM6vfLNHr51LsWODhDpg4Qt2I0/qe+D8AJ5Az+5WIWaZEJuBNrcpd12 Egqp476+lZP8Bu56pqQ0LOz0MgkddYraU9swWzlph4PuYLVEH7svJS/pTaDfNM4SWdS3 XRNKFKYjHQcAnsJjN72T6qd9vGJ3jd3G7sU2s/h7+B2KtQn7XfEuruv06EQefpXDiMQU bghQ== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=F3JQdtGSf6KC2mkgWfuW6xub1eB0h7uF3EaQFIITmoM=; b=ePrWSv4SU0Thr7fYzLzxJzfXZE99yNf5/ICZfZBciZkyoiszin+aWK6FDYHet57A34 +Zns5gnCfaHuy5Eux9oeYGL6MsuMMa4xpByPDYCEy/MN61d4rUzf2pSrtMpRLaHqmyTw SExEC8XVxsauZE4wNUHrmtcXN2eSEK76asiwk8k1JnEQNkW6N/ODTmq8iiYvelti9pe+ g0vmlt21mYlTNM/eFhvO07MuJyzzSfkNEFqYh/CvGnWTeZ8zwGEQUbsOL19Q5dUhPXu2 YALmdB6JocE/CvD96Ml9xZzqJ5QNpWN/egg9J1t8pTEbwE7aISDUXinRIRyGQZE9xdNK pLOw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si11698196edy.408.2021.03.15.16.48.16; Mon, 15 Mar 2021 16:48:38 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232313AbhCOSon (ORCPT + 99 others); Mon, 15 Mar 2021 14:44:43 -0400 Received: from mga07.intel.com ([134.134.136.100]:24292 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbhCOSob (ORCPT ); Mon, 15 Mar 2021 14:44:31 -0400 IronPort-SDR: 0wwzIrJpxMNNNFW4cLUZY0HUgkcY0Qv8cqAe0NbB8iDZTJftUqbZ4l4KDzTGQ9pVlOeyY8cPHY dZFP37mYh45Q== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="253154950" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="253154950" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2021 11:44:27 -0700 IronPort-SDR: GFBLKvJVxYXOZ4sXiVf+of8xkR8iT1GQngpxTJJ1mKq1mdQjXAnDcBU3J+CfTwzUROstMABWAM CAhRPfECjhbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="371724628" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 15 Mar 2021 11:44:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 835C411C; Mon, 15 Mar 2021 20:44:36 +0200 (EET) From: Andy Shevchenko To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 1/1] gpiolib: Assign fwnode to parent's if no primary one provided Date: Mon, 15 Mar 2021 20:44:30 +0200 Message-Id: <20210315184430.17755-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case when the properties are supplied in the secondary fwnode (for example, built-in device properties) the fwnode pointer left unassigned. This makes unable to retrieve them. Assign fwnode to parent's if no primary one provided. Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Fixes: 2afa97e9868f ("gpiolib: Read "gpio-line-names" from a firmware node") Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7ec0822c0505..569c62863748 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -571,6 +571,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, struct lock_class_key *lock_key, struct lock_class_key *request_key) { + struct fwnode_handle *fwnode = gc->parent ? dev_fwnode(gc->parent) : NULL; unsigned long flags; int ret = 0; unsigned i; @@ -594,6 +595,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, of_gpio_dev_init(gc, gdev); + /* + * Assign fwnode depending on the result of the previous calls, + * if none of them succeed, assign it to the parent's one. + */ + gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; + gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); if (gdev->id < 0) { ret = gdev->id; -- 2.30.2