Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31EA1C678D4 for ; Tue, 7 Mar 2023 10:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZqBSxKjagF7RL733dA6+RTmYiExiuuIe++M8q+eq66E=; b=kwsQHNcDpjaGd+ rkivrimVejbId18PLfCtlvjgRpCXkv408V9x9152IvcQzLV2EPZrQigu2d/mdb+AAUPdqtEk2T6LY 0Neyk6Ezv+wTuTICbLtBtF17HRdJd7GzvAOBNbsurqrXwW5kK+8HLpZ7TvR47Oq4NR9yKa+n6atzf DEKXEpSLXJ9EzTY9uzgvvXNgUWQSiMDQ7OCLdQ3YvOock53hwbEfFYz0YmBcAxpvLmWJ9ELzJ9nzC ncwhbVKFJk4jzYTaN7CHyvJIVkysicOLiaLjDMVh9xCzNXSqxaPITn5qQI4ZhoJyuKWzlQDMoMETZ k8BqkBg1cR8hAaOrBg8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZUZl-00HHRi-F3; Tue, 07 Mar 2023 10:29:45 +0000 Received: from mx2.securetransport.de ([188.68.39.254]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZUZh-00HHO5-IA for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 10:29:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1678184235; bh=BFTwUDeGFqh4A6+N9nOPx07VhAZjWjW2pJsFRPj4D7s=; h=From:To:CC:Subject:Date:References:In-Reply-To:From; b=usJiyu4qwKjoxQ0qJAi6sONGVcqwQMGygNZQIdozYcmHxFj3rS/GaVt5jVyFi8d7B 0JS5Cvdgl4YEi3ndRlr2zdipL1Y+ExF+685btufIAjXimFdPDSUeYBLcF7XxSamQqY QWWKJvS4zYd0PZI/3VPCSsPurtSvsukHDdAlV8dkN8wAUpcEHlW4QmxYj9DAfHSQxl n0UcAzL1B6zy57dG5zge3JlwwzBj8bfzlAYuZkTC6uEcOLIt7FOAuQdqUN8rj53pyR ByHm+UcqzMaScFcZVLpwUqzWhO1VljKmOEVGxmSMP3KGo3Xfto0jIM9O3DWEl5lZ/9 9HxYqE9HuQmCQ== X-secureTransport-forwarded: yes From: Christoph Niedermaier Complaints-To: abuse@cubewerk.de To: Lee Jones CC: "linux-arm-kernel@lists.infradead.org" , Support Opensource , Adam Thomson , Liam Girdwood , Mark Brown , Marek Vasut , kernel , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH V2 1/2] mfd: da9062: Remove IRQ requirement Thread-Topic: [PATCH V2 1/2] mfd: da9062: Remove IRQ requirement Thread-Index: AQHZPHSeb7eUOHEwkkmsB+GOZ+9epq7ozlWAgAZufVA= Date: Tue, 7 Mar 2023 10:17:04 +0000 Message-ID: References: <20230209105144.9351-1-cniedermaier@dh-electronics.com> <20230303084153.GI2303077@google.com> In-Reply-To: <20230303084153.GI2303077@google.com> Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_022942_013648_51F22B56 X-CRM114-Status: GOOD ( 28.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lee Jones [mailto:lee@kernel.org] Sent: Friday, March 3, 2023 9:42 AM > > On Thu, 09 Feb 2023, Christoph Niedermaier wrote: > >> This patch removes the requirement for an IRQ, because for the core >> functionality IRQ isn't needed. So this makes the DA9061/62 chip >> useable for designs which haven't connected the IRQ pin. >> >> Signed-off-by: Christoph Niedermaier >> --- >> Cc: Support Opensource >> Cc: Lee Jones >> Cc: Adam Thomson >> Cc: Liam Girdwood >> Cc: Mark Brown >> Cc: Marek Vasut >> Cc: kernel@dh-electronics.com >> Cc: linux-kernel@vger.kernel.org >> To: linux-arm-kernel@lists.infradead.org >> --- >> V2: - Rebase on current next 20230209 >> - Add Lee Jones to Cc list >> --- >> drivers/mfd/da9062-core.c | 98 +++++++++++++++++++++++++++++++++++------------ >> 1 file changed, 73 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c >> index 40cde51e5719..caa597400dd1 100644 >> --- a/drivers/mfd/da9062-core.c >> +++ b/drivers/mfd/da9062-core.c >> @@ -212,6 +212,27 @@ static const struct mfd_cell da9061_devs[] = { >> }, >> }; >> >> +static const struct mfd_cell da9061_devs_without_irq[] = { > > "_noirq" > >> + { >> + .name = "da9061-core", >> + }, >> + { >> + .name = "da9062-regulators", >> + }, > > Place the one line entries on one line please. > > Even better, use MFD_CELL_NAME() > >> + { >> + .name = "da9061-watchdog", >> + .of_compatible = "dlg,da9061-watchdog", >> + }, > > MFD_CELL_OF(, NULL, NULL, NULL, 0, ); > I will convert all to MFD_CELL_NAME() in version 3. >> + { >> + .name = "da9061-thermal", >> + .of_compatible = "dlg,da9061-thermal", >> + }, >> + { >> + .name = "da9061-onkey", >> + .of_compatible = "dlg,da9061-onkey", >> + }, >> +}; >> + >> static const struct resource da9062_core_resources[] = { >> DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ), >> }; >> @@ -288,6 +309,35 @@ static const struct mfd_cell da9062_devs[] = { >> }, >> }; >> >> +static const struct mfd_cell da9062_devs_without_irq[] = { >> + { >> + .name = "da9062-core", >> + }, >> + { >> + .name = "da9062-regulators", >> + }, >> + { >> + .name = "da9062-watchdog", >> + .of_compatible = "dlg,da9062-watchdog", >> + }, >> + { >> + .name = "da9062-thermal", >> + .of_compatible = "dlg,da9062-thermal", >> + }, >> + { >> + .name = "da9062-rtc", >> + .of_compatible = "dlg,da9062-rtc", >> + }, >> + { >> + .name = "da9062-onkey", >> + .of_compatible = "dlg,da9062-onkey", >> + }, >> + { >> + .name = "da9062-gpio", >> + .of_compatible = "dlg,da9062-gpio", >> + }, >> +}; > > As above. > I will convert all to MFD_CELL_NAME() in version 3. >> static int da9062_clear_fault_log(struct da9062 *chip) >> { >> int ret; >> @@ -625,7 +675,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c) >> { >> const struct i2c_device_id *id = i2c_client_get_device_id(i2c); >> struct da9062 *chip; >> - unsigned int irq_base; >> + unsigned int irq_base = 0; >> const struct mfd_cell *cell; >> const struct regmap_irq_chip *irq_chip; >> const struct regmap_config *config; >> @@ -645,21 +695,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c) >> i2c_set_clientdata(i2c, chip); >> chip->dev = &i2c->dev; >> >> - if (!i2c->irq) { >> - dev_err(chip->dev, "No IRQ configured\n"); >> - return -EINVAL; >> - } >> - >> switch (chip->chip_type) { >> case COMPAT_TYPE_DA9061: >> - cell = da9061_devs; >> - cell_num = ARRAY_SIZE(da9061_devs); >> + cell = i2c->irq ? da9061_devs : da9061_devs_without_irq; >> + cell_num = i2c->irq ? ARRAY_SIZE(da9061_devs) : ARRAY_SIZE(da9061_devs_without_irq); > > This is hideous. > > Why not just NULLify the resources below instead? > >> irq_chip = &da9061_irq_chip; >> config = &da9061_regmap_config; >> break; >> case COMPAT_TYPE_DA9062: >> - cell = da9062_devs; >> - cell_num = ARRAY_SIZE(da9062_devs); >> + cell = i2c->irq ? da9062_devs : da9062_devs_without_irq; >> + cell_num = i2c->irq ? ARRAY_SIZE(da9062_devs) : ARRAY_SIZE(da9062_devs_without_irq); > > irq_chip = &da9062_irq_chip; > > Still setting this despite no IRQs? I will take it into account in version 3. > >> config = &da9062_regmap_config; >> break; > __ > _||_ > \ / > \/ > > [...] > > if (i2c->irq <= 0) > cell->resources = NULL; > cell->num_resources = 0; But it is an array. I then have to go through it completely and check if it is related to IRQ. I will try to refactor the my code to be less hideous and send a version 3. > >> @@ -695,29 +740,32 @@ static int da9062_i2c_probe(struct i2c_client *i2c) >> if (ret) >> return ret; >> >> - ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); >> - if (ret < 0) { >> - dev_err(chip->dev, "Failed to configure IRQ type\n"); >> - return ret; >> - } >> + if (i2c->irq) { >> + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); >> + if (ret < 0) { >> + dev_err(chip->dev, "Failed to configure IRQ type\n"); >> + return ret; >> + } >> >> - ret = regmap_add_irq_chip(chip->regmap, i2c->irq, >> - trigger_type | IRQF_SHARED | IRQF_ONESHOT, >> - -1, irq_chip, &chip->regmap_irq); >> - if (ret) { >> - dev_err(chip->dev, "Failed to request IRQ %d: %d\n", >> - i2c->irq, ret); >> - return ret; >> - } >> + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, >> + trigger_type | IRQF_SHARED | IRQF_ONESHOT, >> + -1, irq_chip, &chip->regmap_irq); >> + if (ret) { >> + dev_err(chip->dev, "Failed to request IRQ %d: %d\n", >> + i2c->irq, ret); >> + return ret; >> + } >> >> - irq_base = regmap_irq_chip_get_base(chip->regmap_irq); >> + irq_base = regmap_irq_chip_get_base(chip->regmap_irq); >> + } >> >> ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell, >> cell_num, NULL, irq_base, >> NULL); >> if (ret) { >> dev_err(chip->dev, "Cannot register child devices\n"); >> - regmap_del_irq_chip(i2c->irq, chip->regmap_irq); >> + if (i2c->irq) >> + regmap_del_irq_chip(i2c->irq, chip->regmap_irq); >> return ret; >> } >> Regards Christoph _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel