From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> To: Ryan Chen <ryan_chen@aspeedtech.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>, Philipp Zabel <p.zabel@pengutronix.de>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: Re: [PATCH v5 2/2] i2c: aspeed: support ast2600 i2cv2 new register mode driver Date: Wed, 22 Feb 2023 09:28:26 +0100 [thread overview] Message-ID: <77480142-a2c0-f6da-af0e-d3f01f72ac53@linaro.org> (raw) In-Reply-To: <SEZPR06MB5269B032022D3D7286E59D36F2AA9@SEZPR06MB5269.apcprd06.prod.outlook.com> On 22/02/2023 04:36, Ryan Chen wrote: >>> + >>> + return 0; >>> + >>> +free_irq: >>> + devm_free_irq(&pdev->dev, i2c_bus->irq, i2c_bus); >> >> Why? >> >>> +unmap: >>> + devm_iounmap(&pdev->dev, i2c_bus->reg_base); >> >> Why? >> >>> +free_mem: >>> + devm_kfree(&pdev->dev, i2c_bus); >> >> Why? >> > > Sorry, those are probe following, if any error, will goto this label. > To release mem/unmap/free_irq. Is this unnecessary? Releasing managed resources is usualyl unnecessary. Therefore I am asking why do you think it is necessary here? > I saw many driver submit is remove all probe fail goto label, is just return ERR. > Do you mean I direct go for this way? Why would you do it differently? > >>> + >>> + return ret; >>> +} >>> + >>> +static int ast2600_i2c_remove(struct platform_device *pdev) { >>> + struct ast2600_i2c_bus *i2c_bus = platform_get_drvdata(pdev); >>> + >>> + /* Disable everything. */ >>> + writel(0, i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL); >>> + writel(0, i2c_bus->reg_base + AST2600_I2CM_IER); >>> + >>> + devm_free_irq(&pdev->dev, i2c_bus->irq, i2c_bus); >>> + >>> + i2c_del_adapter(&i2c_bus->adap); >> >> Wrong order of cleanup. It should be reversed to the probe, unless you have >> some reason, but then please explain. > > Sorry, this in remove function, it should do i2c_del_adapter(&i2c_bus->adap) in the end. > Why this should revered to probe? Because it's logical, you do the same with error paths of probe, it it usually the only way to make sure some of the resources are not used by some other piece (e.g. interrupt handler is called while i2c adapter is unregistered). Best regards, Krzysztof
WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> To: Ryan Chen <ryan_chen@aspeedtech.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>, Philipp Zabel <p.zabel@pengutronix.de>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: Re: [PATCH v5 2/2] i2c: aspeed: support ast2600 i2cv2 new register mode driver Date: Wed, 22 Feb 2023 09:28:26 +0100 [thread overview] Message-ID: <77480142-a2c0-f6da-af0e-d3f01f72ac53@linaro.org> (raw) In-Reply-To: <SEZPR06MB5269B032022D3D7286E59D36F2AA9@SEZPR06MB5269.apcprd06.prod.outlook.com> On 22/02/2023 04:36, Ryan Chen wrote: >>> + >>> + return 0; >>> + >>> +free_irq: >>> + devm_free_irq(&pdev->dev, i2c_bus->irq, i2c_bus); >> >> Why? >> >>> +unmap: >>> + devm_iounmap(&pdev->dev, i2c_bus->reg_base); >> >> Why? >> >>> +free_mem: >>> + devm_kfree(&pdev->dev, i2c_bus); >> >> Why? >> > > Sorry, those are probe following, if any error, will goto this label. > To release mem/unmap/free_irq. Is this unnecessary? Releasing managed resources is usualyl unnecessary. Therefore I am asking why do you think it is necessary here? > I saw many driver submit is remove all probe fail goto label, is just return ERR. > Do you mean I direct go for this way? Why would you do it differently? > >>> + >>> + return ret; >>> +} >>> + >>> +static int ast2600_i2c_remove(struct platform_device *pdev) { >>> + struct ast2600_i2c_bus *i2c_bus = platform_get_drvdata(pdev); >>> + >>> + /* Disable everything. */ >>> + writel(0, i2c_bus->reg_base + AST2600_I2CC_FUN_CTRL); >>> + writel(0, i2c_bus->reg_base + AST2600_I2CM_IER); >>> + >>> + devm_free_irq(&pdev->dev, i2c_bus->irq, i2c_bus); >>> + >>> + i2c_del_adapter(&i2c_bus->adap); >> >> Wrong order of cleanup. It should be reversed to the probe, unless you have >> some reason, but then please explain. > > Sorry, this in remove function, it should do i2c_del_adapter(&i2c_bus->adap) in the end. > Why this should revered to probe? Because it's logical, you do the same with error paths of probe, it it usually the only way to make sure some of the resources are not used by some other piece (e.g. interrupt handler is called while i2c adapter is unregistered). Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-22 8:28 UTC|newest] Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-20 6:17 [PATCH v5 0/2] Add ASPEED AST2600 I2Cv2 controller driver Ryan Chen 2023-02-20 6:17 ` Ryan Chen 2023-02-20 6:17 ` [PATCH v5 1/2] dt-bindings: i2c: Add support for ASPEED i2Cv2 Ryan Chen 2023-02-20 6:17 ` Ryan Chen 2023-02-20 8:28 ` Jeremy Kerr 2023-02-20 8:28 ` Jeremy Kerr 2023-02-20 9:50 ` Ryan Chen 2023-02-20 9:50 ` Ryan Chen 2023-02-20 10:43 ` Krzysztof Kozlowski 2023-02-20 10:43 ` Krzysztof Kozlowski 2023-02-20 11:24 ` Jeremy Kerr 2023-02-20 11:24 ` Jeremy Kerr 2023-02-21 3:32 ` Ryan Chen 2023-02-21 3:32 ` Ryan Chen 2023-02-21 9:43 ` Krzysztof Kozlowski 2023-02-21 9:43 ` Krzysztof Kozlowski 2023-02-22 1:14 ` Dhananjay Phadke 2023-02-22 1:14 ` Dhananjay Phadke 2023-02-22 1:30 ` Jeremy Kerr 2023-02-22 1:30 ` Jeremy Kerr 2023-02-20 8:35 ` Krzysztof Kozlowski 2023-02-20 8:35 ` Krzysztof Kozlowski 2023-02-21 2:43 ` Ryan Chen 2023-02-21 2:43 ` Ryan Chen 2023-02-21 9:40 ` Krzysztof Kozlowski 2023-02-21 9:40 ` Krzysztof Kozlowski 2023-02-21 10:42 ` Ryan Chen 2023-02-21 10:42 ` Ryan Chen 2023-02-21 11:04 ` Krzysztof Kozlowski 2023-02-21 11:04 ` Krzysztof Kozlowski 2023-02-22 2:59 ` Ryan Chen 2023-02-22 2:59 ` Ryan Chen 2023-02-22 8:25 ` Krzysztof Kozlowski 2023-02-22 8:25 ` Krzysztof Kozlowski 2023-02-22 10:31 ` Ryan Chen 2023-02-22 10:31 ` Ryan Chen 2023-02-22 10:35 ` Krzysztof Kozlowski 2023-02-22 10:35 ` Krzysztof Kozlowski 2023-02-22 10:47 ` Ryan Chen 2023-02-22 10:47 ` Ryan Chen 2023-02-23 9:28 ` Krzysztof Kozlowski 2023-02-23 9:28 ` Krzysztof Kozlowski 2023-02-23 10:25 ` Ryan Chen 2023-02-23 10:25 ` Ryan Chen 2023-02-20 6:17 ` [PATCH v5 2/2] i2c: aspeed: support ast2600 i2cv2 new register mode driver Ryan Chen 2023-02-20 6:17 ` Ryan Chen 2023-02-20 8:43 ` Krzysztof Kozlowski 2023-02-20 8:43 ` Krzysztof Kozlowski 2023-02-20 10:44 ` Krzysztof Kozlowski 2023-02-20 10:44 ` Krzysztof Kozlowski 2023-02-22 3:36 ` Ryan Chen 2023-02-22 3:36 ` Ryan Chen 2023-02-22 8:28 ` Krzysztof Kozlowski [this message] 2023-02-22 8:28 ` Krzysztof Kozlowski 2023-02-23 0:58 ` Ryan Chen 2023-02-23 0:58 ` Ryan Chen 2023-02-23 9:30 ` Krzysztof Kozlowski 2023-02-23 9:30 ` Krzysztof Kozlowski 2023-02-20 8:30 ` [PATCH v5 0/2] Add ASPEED AST2600 I2Cv2 controller driver Krzysztof Kozlowski 2023-02-20 8:30 ` Krzysztof Kozlowski 2023-02-20 9:56 ` Ryan Chen 2023-02-20 9:56 ` Ryan Chen 2023-02-20 10:35 ` Krzysztof Kozlowski 2023-02-20 10:35 ` Krzysztof Kozlowski 2023-02-21 1:12 ` Ryan Chen 2023-02-21 1:12 ` Ryan Chen 2023-02-21 9:38 ` Krzysztof Kozlowski 2023-02-21 9:38 ` Krzysztof Kozlowski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=77480142-a2c0-f6da-af0e-d3f01f72ac53@linaro.org \ --to=krzysztof.kozlowski@linaro.org \ --cc=andrew@aj.id.au \ --cc=joel@jms.id.au \ --cc=krzysztof.kozlowski+dt@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-aspeed@lists.ozlabs.org \ --cc=linux-kernel@vger.kernel.org \ --cc=openbmc@lists.ozlabs.org \ --cc=p.zabel@pengutronix.de \ --cc=robh+dt@kernel.org \ --cc=ryan_chen@aspeedtech.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.