From patchwork Thu Jul 16 12:03:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 235641 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp727504ilg; Thu, 16 Jul 2020 05:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBoHUV3dgucL5aEGkqZ9r2JdAcBt2o5n4rf8Z+1g5czv3zlIpMfU20P6lENvyoNUlnEkRo X-Received: by 2002:aa7:c398:: with SMTP id k24mr4076578edq.95.1594901004420; Thu, 16 Jul 2020 05:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594901004; cv=none; d=google.com; s=arc-20160816; b=PNeVZpn1SQ/AgwE8Uz8DSiZ8Ag9+zsNxSk3MSNuErsUEUMNEOOMbMGYJgJnDY5g/oK LVlRwakpvddOA8X7KvJyTkPeQUrRNjK5cBv0Feh6nnAlTXDP3hjUSfdHqKshgC6hwpTc RPJE0DV8ec5WdKR19LUUv3vb4+vTHlMEYERXeeZRhthebg9QZVAHHsbBycOLgrGF8s9H 6JgH+h8GYT1cgg+67a5wn7BX/KidysruwlSp+RN73Sc+T9WPjQURcmrO+Cr23ZELBKo1 ARCv8hN9k2H3jwh2KIJBfnJzEUVZpRLk3v9BtPXzY5NXXPZeb2v5URqHtWgqXPS3o214 kkTw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Pm90CMDs5KAJRgf5IT/u/TpwXqN+8gJ40rj0jB1tHi8=; b=NhzsVvy5648GsmGogWuoijOQ6aThlKeF6G5BnNRBFgEMcQZRWAeWzNimbNHYIBZg9o aXMkFoJ3bYiZdpulqXv8FrxgX274NOBD4bIsGvnFcluxLZDNOzOZHZREM5C+GAHVJ5Ee BwtihkaGgMfHMRz1Sa4d4bMEL550tadVz0f+eWj0Dxj8imFXpzDUTm0XIYVJxVQiyT8j qrVteCer9bUdQ2yUrxd7nM3F5xFf1zadY/Sl8MifEwRf0a8aB+BmV28Kbfbwjgg+Fjaf yNVqdMr5tuN2JHz3juLHBP9wUSrOCHGLTcSHLBD5VaVdVLhPn9cm1gA5qxbfsCMehtjF 37uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWpjMRqc; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx8si2950621edb.170.2020.07.16.05.03.24; Thu, 16 Jul 2020 05:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-gpio-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=@linaro.org header.s=google header.b=EWpjMRqc; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726383AbgGPMDX (ORCPT + 5 others); Thu, 16 Jul 2020 08:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgGPMDX (ORCPT ); Thu, 16 Jul 2020 08:03:23 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCF94C061755 for ; Thu, 16 Jul 2020 05:03:22 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id s9so6800501ljm.11 for ; Thu, 16 Jul 2020 05:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Pm90CMDs5KAJRgf5IT/u/TpwXqN+8gJ40rj0jB1tHi8=; b=EWpjMRqc1Oyp5cvqbT8tnnj1NGXI61gKswFRMeb68LRB10x4KdJlIWvNd9FqM/9ILq gKJg8V0dPKFONEzU/hzo93jyMGMoxUX1SJwAlijdG6ba1/d7p6zZgxU17ANSUe7KK7Mh DjdHHBYsxeH5OgXy3xetuyBkHOSoFFlD/7971yo4JXh/v9ayQORT4h48zmZrBcCAezMz w/390KYGbQYyIETjGBXNdRpG7K2VGUBCkU/whXgN73yekcjfxAMJbJU6nbkMSoPk+p02 XNlN/oIopf8OtBVooon1+nU5HAclBhQzkWQnN8gJaXOhlkMx8rUBrnS23h2HvPy8J9rO JcxQ== 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=Pm90CMDs5KAJRgf5IT/u/TpwXqN+8gJ40rj0jB1tHi8=; b=t7sbgoo2+axvkCBpOHE8QZQOv2M/uiRc/LKQxDaGRfni1qjb2mhUVbiG9TcExvtMwc Nm7OqojSksYwOKVLrROlsa+cI+R5VfNDlrd4a0POuK1JnrNp+nfl8bA8aldzv0l6b9mL NWQwLThmVQMkuX2HNwviSDIMayWaNC8GOZg80Y4i+jzwVbfGFtRMrmoQSTZqi1QqlVJd mHyftnJa+TSx5JSakbPL5oWOUc+QPVqzq9LEK2HnN3R3nLo/hT8AWc2dfTzuZJlDeZzw JpOTuX3K3cOFA2pYPzknxSu4R1o8aHUA/7ZDZ4NQOoTrmxA9q4K8WxyOAab3XolO3H0s 2JBw== X-Gm-Message-State: AOAM531a3NWqO79SVpQ/LXCFb7Uxs3VPEOmt6Ua+2+mC5Z1QcoPAmnlV DxensKjlhzXpwNYwWnird8uuZw77UE4= X-Received: by 2002:a2e:b054:: with SMTP id d20mr1755871ljl.55.1594901001028; Thu, 16 Jul 2020 05:03:21 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v5sm998402lji.75.2020.07.16.05.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 05:03:20 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , Roland Stigge , Lars Poeschel Subject: [PATCH] gpio: adnp: Use irqchip template Date: Thu, 16 Jul 2020 14:03:18 +0200 Message-Id: <20200716120318.127176-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit calls to gpiochip_irqchip_add_nested() and gpiochip_set_nested_irqchip(). The irqchip is instead added while adding the gpiochip. Cc: Roland Stigge Cc: Lars Poeschel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-adnp.c | 95 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 47 deletions(-) -- 2.26.2 diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index b9fcaab2a931..8eedfc6451df 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -238,36 +238,6 @@ static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) mutex_unlock(&adnp->i2c_lock); } -static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios) -{ - struct gpio_chip *chip = &adnp->gpio; - int err; - - adnp->reg_shift = get_count_order(num_gpios) - 3; - - chip->direction_input = adnp_gpio_direction_input; - chip->direction_output = adnp_gpio_direction_output; - chip->get = adnp_gpio_get; - chip->set = adnp_gpio_set; - chip->can_sleep = true; - - if (IS_ENABLED(CONFIG_DEBUG_FS)) - chip->dbg_show = adnp_gpio_dbg_show; - - chip->base = -1; - chip->ngpio = num_gpios; - chip->label = adnp->client->name; - chip->parent = &adnp->client->dev; - chip->of_node = chip->parent->of_node; - chip->owner = THIS_MODULE; - - err = devm_gpiochip_add_data(&adnp->client->dev, chip, adnp); - if (err) - return err; - - return 0; -} - static irqreturn_t adnp_irq(int irq, void *data) { struct adnp *adnp = data; @@ -464,18 +434,54 @@ static int adnp_irq_setup(struct adnp *adnp) return err; } - err = gpiochip_irqchip_add_nested(chip, - &adnp_irq_chip, - 0, - handle_simple_irq, - IRQ_TYPE_NONE); - if (err) { - dev_err(chip->parent, - "could not connect irqchip to gpiochip\n"); - return err; + return 0; +} + +static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios, + bool is_irq_controller) +{ + struct gpio_chip *chip = &adnp->gpio; + int err; + + adnp->reg_shift = get_count_order(num_gpios) - 3; + + chip->direction_input = adnp_gpio_direction_input; + chip->direction_output = adnp_gpio_direction_output; + chip->get = adnp_gpio_get; + chip->set = adnp_gpio_set; + chip->can_sleep = true; + + if (IS_ENABLED(CONFIG_DEBUG_FS)) + chip->dbg_show = adnp_gpio_dbg_show; + + chip->base = -1; + chip->ngpio = num_gpios; + chip->label = adnp->client->name; + chip->parent = &adnp->client->dev; + chip->of_node = chip->parent->of_node; + chip->owner = THIS_MODULE; + + if (is_irq_controller) { + struct gpio_irq_chip *girq; + + err = adnp_irq_setup(adnp); + if (err) + return err; + + girq = &chip->irq; + girq->chip = &adnp_irq_chip; + /* This will let us handle the parent IRQ in the driver */ + girq->parent_handler = NULL; + girq->num_parents = 0; + girq->parents = NULL; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_simple_irq; + girq->threaded = true; } - gpiochip_set_nested_irqchip(chip, &adnp_irq_chip, adnp->client->irq); + err = devm_gpiochip_add_data(&adnp->client->dev, chip, adnp); + if (err) + return err; return 0; } @@ -503,16 +509,11 @@ static int adnp_i2c_probe(struct i2c_client *client, mutex_init(&adnp->i2c_lock); adnp->client = client; - err = adnp_gpio_setup(adnp, num_gpios); + err = adnp_gpio_setup(adnp, num_gpios, + of_property_read_bool(np, "interrupt-controller")); if (err) return err; - if (of_find_property(np, "interrupt-controller", NULL)) { - err = adnp_irq_setup(adnp); - if (err) - return err; - } - i2c_set_clientdata(client, adnp); return 0;