From patchwork Thu Sep 17 07:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44109C43461 for ; Thu, 17 Sep 2020 07:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F74F21973 for ; Thu, 17 Sep 2020 07:49:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="ZXzXz46o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbgIQHtH (ORCPT ); Thu, 17 Sep 2020 03:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbgIQHtG (ORCPT ); Thu, 17 Sep 2020 03:49:06 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70BEC061788 for ; Thu, 17 Sep 2020 00:49:06 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id o5so1284876qke.12 for ; Thu, 17 Sep 2020 00:49:06 -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:mime-version :content-transfer-encoding; bh=ZKJHKk7vG3da0ptMNHqr0ZH7librM+LR8T0+DdZdF4M=; b=ZXzXz46o2tHEdoZfj427WwyXF5XwFye1GOfw+mLenLLXV0ueZgYC1pcYj3lYMxGu3O u9Z21GE3b8lgMynuSLz0WpjzT2x6MzjDI8WCfQY7wND/MbNP3i14vroVqXAybUvtYC/I UiWcKbmcFNN664FeX5JQQHlbVfgav9HJTyuL8eExMXb8sbL5kr+E3JIuHlgaf9zt3NBN 7rafP5yu1KT2YGTZUje00lgvuSRI5Em3InKyKKekVuUT2fIV0rcf6qvqNL+xKpB4nCgJ BBNAbkX1UEYNRCZgPH8TWGvArylDH4vm9B0sFqABcHnnDkI8EKlxiXyS1yIJpp+1BpV2 q/Nw== 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:mime-version :content-transfer-encoding; bh=ZKJHKk7vG3da0ptMNHqr0ZH7librM+LR8T0+DdZdF4M=; b=AB69DLyAfMIyascpWOfkjfn640mWMKBBJimK05GT1TF/30cDfq3gkt3bUKz0r4Q3JD NVurCIpvrlQyud/63r1aiYKVDcmMlUJFAHPx6a4daem5rmgsvJIf1C61Nl0Ra7rWwecJ 7bHn/1O48HLGXodk4axpk634RS1UYBJIdQhT+TeOOcd+euRhQ9yNzBa3hnvQK7JQcAUd 1sBtKeFcP34nSUc2XlK4i+43mZtiUku5aLgIIe1UgDqrixjLCH5h4fBd17XW1EkswZBr /jwDjNDiUdiwnf9seVAd5u7smLnc6Wf28TpxGRmm4h4A7CvpHVtwFXVs1vdSEAA0GfXl zWCg== X-Gm-Message-State: AOAM532juq5Lr2j0DCyFAEESrrVFiVmzfqlaeNfOBQ7mNmZmow+7BPye K4ctX4l5021VtvEW4rkYuJck/Q== X-Google-Smtp-Source: ABdhPJzWJyaQQuiN+8cGiMTVoympH5kdMvCkREdE+9MOy1CGXfAhEUdzcOTU3OzLOUd2seVHXv5nBQ== X-Received: by 2002:a37:9d84:: with SMTP id g126mr27322880qke.473.1600328945938; Thu, 17 Sep 2020 00:49:05 -0700 (PDT) Received: from localhost.localdomain (amontpellier-657-1-17-60.w109-210.abo.wanadoo.fr. [109.210.64.60]) by smtp.gmail.com with ESMTPSA id q19sm3153736qtk.74.2020.09.17.00.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 00:49:05 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Mika Westerberg , Andy Shevchenko , Kent Gibson , Anders Roxell Cc: linux-gpio@vger.kernel.org, linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH next v2] gpiolib: check for parent device in devprop_gpiochip_set_names() Date: Thu, 17 Sep 2020 09:48:57 +0200 Message-Id: <20200917074857.6716-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski It's possible for a GPIO chip to not have a parent device (whose properties we inspect for 'gpio-line-names'). In this case we should simply return from devprop_gpiochip_set_names(). Add an appropriate check for this use-case. Fixes: 7cba1a4d5e16 ("gpiolib: generalize devprop_gpiochip_set_names() for device properties") Reported-by: Anders Roxell Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Tested-by: Anders Roxell Reviewed-by: Mika Westerberg --- v1 -> v2: - added a comment as requested by Andy drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b7b608ef9e6b..dfcff5d24b18 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -375,6 +375,10 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) int ret, i; int count; + /* GPIO chip may not have a parent device whose properties we inspect. */ + if (!dev) + return 0; + count = device_property_string_array_count(dev, "gpio-line-names"); if (count < 0) return 0;