[PATCH] pinctrl: sh-pfc: Use seq_puts() in sh_pfc_pin_dbg_show()
From: Markus Elfring Date: Sat, 6 Jan 2018 21:50:20 +0100 A string which did not contain a data format specification should be put into a sequence. Thus use the corresponding function "seq_puts". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/pinctrl/sh-pfc/pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 736634aee500..70db21638901 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -75,7 +75,7 @@ static int sh_pfc_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, static void sh_pfc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned offset) { - seq_printf(s, "%s", DRV_NAME); + seq_puts(s, DRV_NAME); } #ifdef CONFIG_OF -- 2.15.1
[PATCH v2] PCI: rcar: Use common error handling code in rcar_pcie_enable_msi()
From: Markus Elfring Date: Thu, 2 Nov 2017 13:35:17 +0100 * Adjust a jump target so that a specific error message is stored only once at the end of this function implementation. * Replace two calls of the function "dev_err" by goto statements. This issue was detected by using the Coccinelle software. Link: https://lkml.org/lkml/2017/11/2/140 Link: https://lkml.kernel.org/r/<20171102081239.bzaunax3uotej...@verge.net.au> Signed-off-by: Markus Elfring --- v2: An other jump label was requested by Simon Horman. drivers/pci/host/pcie-rcar.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 12796eccb2be..f3c1ffdf8072 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -873,18 +873,14 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) err = devm_request_irq(dev, msi->irq1, rcar_pcie_msi_irq, IRQF_SHARED | IRQF_NO_THREAD, rcar_msi_irq_chip.name, pcie); - if (err < 0) { - dev_err(dev, "failed to request IRQ: %d\n", err); - goto err; - } + if (err < 0) + goto err_remove_domain; err = devm_request_irq(dev, msi->irq2, rcar_pcie_msi_irq, IRQF_SHARED | IRQF_NO_THREAD, rcar_msi_irq_chip.name, pcie); - if (err < 0) { - dev_err(dev, "failed to request IRQ: %d\n", err); - goto err; - } + if (err < 0) + goto err_remove_domain; /* setup MSI data target */ msi->pages = __get_free_pages(GFP_KERNEL, 0); @@ -898,7 +894,8 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return 0; -err: +err_remove_domain: + dev_err(dev, "failed to request IRQ: %d\n", err); irq_domain_remove(msi->domain); return err; } -- 2.15.0
[PATCH v2 2/2] drm/rcar-du: Adjust 14 checks for null pointers
From: Markus Elfring Date: Wed, 1 Nov 2017 16:00:46 +0100 The script "checkpatch.pl" pointed information out like the following. Comparison to NULL could be written !... Thus fix the affected source code places. Signed-off-by: Markus Elfring --- v2: The commit message was written only with ASCII characters. drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 301ea1a8018e..67567af6e348 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -410,7 +410,7 @@ void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc) rcrtc->event = NULL; spin_unlock_irqrestore(&dev->event_lock, flags); - if (event == NULL) + if (!event) return; spin_lock_irqsave(&dev->event_lock, flags); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index d2f29e6b1112..cf80476783bf 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -318,7 +318,7 @@ static int rcar_du_probe(struct platform_device *pdev) /* Allocate and initialize the R-Car device structure. */ rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL); - if (rcdu == NULL) + if (!rcdu) return -ENOMEM; rcdu->dev = &pdev->dev; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c index ba8d2804c1d1..8a9f7fa69ecc 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c @@ -166,7 +166,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, int ret; renc = devm_kzalloc(rcdu->dev, sizeof(*renc), GFP_KERNEL); - if (renc == NULL) + if (!renc) return -ENOMEM; renc->output = output; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index b6b341164aab..c15aa38fe308 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -181,7 +181,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, unsigned int i; format = rcar_du_format_info(mode_cmd->pixel_format); - if (format == NULL) { + if (!format) { dev_dbg(dev->dev, "unsupported pixel format %08x\n", mode_cmd->pixel_format); return ERR_PTR(-EINVAL); @@ -419,7 +419,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu) { rcdu->props.alpha = drm_property_create_range(rcdu->ddev, 0, "alpha", 0, 255); - if (rcdu->props.alpha == NULL) + if (!rcdu->props.alpha) return -ENOMEM; /* @@ -430,7 +430,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu) rcdu->props.colorkey = drm_property_create_range(rcdu->ddev, 0, "colorkey", 0, 0x01ff); - if (rcdu->props.colorkey == NULL) + if (!rcdu->props.colorkey) return -ENOMEM; return 0; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c index b373ad48ef5f..189e71b3d5d4 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c @@ -63,7 +63,7 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu, int ret; rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL); - if (rcon == NULL) + if (!rcon) return -ENOMEM; connector = &rcon->connector; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c index 12d22f3db1af..ab2576e5d700 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c @@ -253,7 +253,7 @@ int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu) for (i = 0; i < rcdu->info->num_lvds; ++i) { lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); - if (lvds == NULL) + if (!lvds) return -ENOMEM; lvds->dev = rcdu; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index 61833cc1c699..f48a990214ed 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -584,7 +584,7 @@ static int rca
[PATCH v2 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init()
From: Markus Elfring Date: Wed, 1 Nov 2017 15:57:31 +0100 * Add a jump target so that a bit of exception handling can be better reused at the end of this function. * Increase the scope for the variable "ret". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- v2: The declaration for the variable "ret" was moved out of a loop. drivers/gpu/drm/rcar-du/rcar_du_kms.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 566d1a948c8f..b6b341164aab 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -365,6 +365,7 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) struct device_node *np = rcdu->dev->of_node; struct device_node *ep_node; unsigned int num_encoders = 0; + int ret; /* * Iterate over the endpoints and create one encoder for each output @@ -374,13 +375,10 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) enum rcar_du_output output; struct of_endpoint ep; unsigned int i; - int ret; ret = of_graph_parse_endpoint(ep_node, &ep); - if (ret < 0) { - of_node_put(ep_node); - return ret; - } + if (ret < 0) + goto put_node; /* Find the output route corresponding to the port number. */ for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) { @@ -401,10 +399,8 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) /* Process the output pipeline. */ ret = rcar_du_encoders_init_one(rcdu, output, &ep); if (ret < 0) { - if (ret == -EPROBE_DEFER) { - of_node_put(ep_node); - return ret; - } + if (ret == -EPROBE_DEFER) + goto put_node; continue; } @@ -413,6 +409,10 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) } return num_encoders; + +put_node: + of_node_put(ep_node); + return ret; } static int rcar_du_properties_init(struct rcar_du_device *rcdu) -- 2.14.3
[PATCH v2 0/2] R-Car Display Unit: Fine-tuning for some function implementations
From: Markus Elfring Date: Wed, 1 Nov 2017 16:23:45 +0100 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): drm/rcar-du: Use common error handling code in rcar_du_encoders_init() drm/rcar-du: Adjust 14 checks for null pointers --- v2: Advice was taken into account from the first round of corresponding source code review. drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 24 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 +++--- 8 files changed, 23 insertions(+), 23 deletions(-) -- 2.14.3
Re: PCI: rcar: Use common error handling code in rcar_pcie_enable_msi()
> This is fine by me Thanks for another bit of change acceptance. > except that the change in the name of the goto label seems spurious. I am curious if the popularity of a jump label like “err” will decrease (in the Linux source files) over time. > But if you really want to change it then as it is an error path > I should suggest it describe that its an error and what unwinding > is done, f.e. err_remove_domain. * Do you get such a kind of information only when the prefix “err_” is added to this identifier? * Do you prefer to stress the “domain removal” (or the shown error message) in the label? Regards, Markus
Re: drm/rcar-du: Use common error handling code in rcar_du_encoders_init()
> In general, I'll pick up any patches that are good, This is usual. > but the current track record is that Markus' patches need extra scrutiny, I find that this can be fine according to a safe review for presented update suggestions. > and many of the patches contain subjective changes that lead to debate Some discussion is occasionally needed to achieve the desired change acceptance, isn't it? > that is not constructive. I got an other opinion here. > There's no return on investment here. I hope that the view can become more positive. How will the clarification evolve further? Regards, Markus
[PATCH] PCI: rcar: Use common error handling code in rcar_pcie_enable_msi()
From: Markus Elfring Date: Mon, 30 Oct 2017 08:28:06 +0100 Adjust a jump target so that a specific error message is stored only once at the end of this function implementation. Replace two calls of the function "dev_err" by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/pci/host/pcie-rcar.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 12796eccb2be..38101f8bebf1 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -873,18 +873,14 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) err = devm_request_irq(dev, msi->irq1, rcar_pcie_msi_irq, IRQF_SHARED | IRQF_NO_THREAD, rcar_msi_irq_chip.name, pcie); - if (err < 0) { - dev_err(dev, "failed to request IRQ: %d\n", err); - goto err; - } + if (err < 0) + goto report_request_failure; err = devm_request_irq(dev, msi->irq2, rcar_pcie_msi_irq, IRQF_SHARED | IRQF_NO_THREAD, rcar_msi_irq_chip.name, pcie); - if (err < 0) { - dev_err(dev, "failed to request IRQ: %d\n", err); - goto err; - } + if (err < 0) + goto report_request_failure; /* setup MSI data target */ msi->pages = __get_free_pages(GFP_KERNEL, 0); @@ -898,7 +894,8 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return 0; -err: +report_request_failure: + dev_err(dev, "failed to request IRQ: %d\n", err); irq_domain_remove(msi->domain); return err; } -- 2.14.3
Re: drm/rcar-du: Use common error handling code in rcar_du_encoders_init()
> Just for the record, I've been bitten in the past by applying one of Markus' > patches that seemed to make sense, only to discover later that it introduced > a > security hole. How do you think about to take another look at the circumstances under which a questionable commit happened in the referenced case? A few glitches occur occasionally. They can be fixed by appropriate collaboration. > I now drop his patches altogether, so could you please keep an eye open > to make sure none of them touching the rcar-du driver will be applied > through drm-misc ? I hope that you can become interested in a more constructive software development dialogue (also with me) again. * Can additional ideas be taken into account here? * Will any other contributor pick related update suggestions up? Regards, Markus
Re: [PATCH] ravb: Use common error handling code in ravb_probe()
>> @@ -2069,10 +2069,9 @@ static int ravb_probe(struct platform_device *pdev) >> irq = platform_get_irq_byname(pdev, "ch22"); >> else >> irq = platform_get_irq(pdev, 0); >> - if (irq < 0) { >> - error = irq; >> - goto out_release; >> - } >> + if (irq < 0) >> + goto failure_indication; > > IMHO, it's really confusing that "irq" contains the error code, not "error". > Especially when jumping to a meaningless label named "failure_indication" > ("irq_failure" would be more intuitive). Thanks for your constructive feedback. > So I prefer the original code, regardless of the label name. Can another attempt make sense to concentrate the setting of a variable at the end of this function with more pleasing identifiers? Regards, Markus
[PATCH] ravb: Use common error handling code in ravb_probe()
From: Markus Elfring Date: Sat, 28 Oct 2017 19:10:08 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/net/ethernet/renesas/ravb_main.c | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index a8822a756e08..62dbdf7de6cd 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2069,10 +2069,9 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "ch22"); else irq = platform_get_irq(pdev, 0); - if (irq < 0) { - error = irq; - goto out_release; - } + if (irq < 0) + goto failure_indication; + ndev->irq = irq; SET_NETDEV_DEV(ndev, &pdev->dev); @@ -2101,25 +2100,22 @@ static int ravb_probe(struct platform_device *pdev) if (chip_id == RCAR_GEN3) { irq = platform_get_irq_byname(pdev, "ch24"); - if (irq < 0) { - error = irq; - goto out_release; - } + if (irq < 0) + goto failure_indication; + priv->emac_irq = irq; for (i = 0; i < NUM_RX_QUEUE; i++) { irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_release; - } + if (irq < 0) + goto failure_indication; + priv->rx_irqs[i] = irq; } for (i = 0; i < NUM_TX_QUEUE; i++) { irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_release; - } + if (irq < 0) + goto failure_indication; + priv->tx_irqs[i] = irq; } } @@ -2226,6 +,10 @@ static int ravb_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); return error; + +failure_indication: + error = irq; + goto out_release; } static int ravb_remove(struct platform_device *pdev) -- 2.14.3
Re: Unicode characters in commit messages?
> These long email threads are a waste of time They occur for different topics. > when we already answered your questions completely There were some attempts for specific details. > and over and over. I hope that further useful adjustments can be achieved for involved information sources. > The feedback was clear. I disagree on some aspects. Regards, Markus
Re: Unicode characters in commit messages?
>> Would you like to support Unicode characters there? > > Multiple people have answered this question already and I have answered > it multiple times. I found the corresponding feedback not sufficient so far to reach a final consensus. Will this topic evolve any further? Regards, Markus
Re: drm/rcar-du: Adjust 14 checks for null pointers
>> The script “checkpatch.pl” pointed information out like the following. >> >> Comparison to NULL could be written !… >> >> Thus fix the affected source code places. >> > > This one is fine This kind of feedback is nice. > except for the commit message. Would you like to support Unicode characters there? Regards, Markus
Re: Clarification for approaches around exception handling
> But anyways I guess other people sometimes disagree with me. Am I one of them? ;-) > Unwinding is for when you allocate five things in a row. This is a general issue. I find that it is also needed in this function as usual. > You have to undo four if the last allocation fails. Concrete numbers might help to clarify another example. > But say you have to take a lock part way through and drop it before > the end of the function. The lock/unlock is not part of the list > of five resources that you want the function to take so it doesn't > belong in the unwind code. Such a view is useful to some degree. > If you add the lock/unlock to the unwind code, then it makes things a > bit tricky because then you have to do funny things like: > > free_four: > free(four); > goto free_three: <-- little bunny hop > unlock: <-- less useful label > unlock(); > free_three: > free_three(); > free_two: > free(two); > free_one: > free(one); > > return ret; > > It's better to just do the unlocking before the goto. I would prefer to store such an action also only so often in the code as it is really required. > That way the lock and unlock are close together. It might look nice occasionally. > if (!four) { > unlock(); > ret = -EFAIL; > goto free_three; > } > > Of course, having a big unlock label makes sense if you take a lock at > the start of the function and need to drop it at the end. But in this > case we are taking a lock then dropping it, and taking the next, then > dropping it and so on. It's a different situation. Lock scopes can interfere with a preferred control flow, can't they? I have got the impression that your detailed reply could have been more appropriate for update suggestions around other software modules. Regards, Markus
[PATCH 2/2] drm/rcar-du: Adjust 14 checks for null pointers
From: Markus Elfring Date: Tue, 24 Oct 2017 17:47:37 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written !… Thus fix the affected source code places. Signed-off-by: Markus Elfring --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 301ea1a8018e..67567af6e348 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -410,7 +410,7 @@ void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc) rcrtc->event = NULL; spin_unlock_irqrestore(&dev->event_lock, flags); - if (event == NULL) + if (!event) return; spin_lock_irqsave(&dev->event_lock, flags); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index d2f29e6b1112..cf80476783bf 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -318,7 +318,7 @@ static int rcar_du_probe(struct platform_device *pdev) /* Allocate and initialize the R-Car device structure. */ rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL); - if (rcdu == NULL) + if (!rcdu) return -ENOMEM; rcdu->dev = &pdev->dev; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c index ba8d2804c1d1..8a9f7fa69ecc 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c @@ -166,7 +166,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, int ret; renc = devm_kzalloc(rcdu->dev, sizeof(*renc), GFP_KERNEL); - if (renc == NULL) + if (!renc) return -ENOMEM; renc->output = output; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index d2c80cc9f8ee..f87c11a3df6c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -181,7 +181,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, unsigned int i; format = rcar_du_format_info(mode_cmd->pixel_format); - if (format == NULL) { + if (!format) { dev_dbg(dev->dev, "unsupported pixel format %08x\n", mode_cmd->pixel_format); return ERR_PTR(-EINVAL); @@ -419,7 +419,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu) { rcdu->props.alpha = drm_property_create_range(rcdu->ddev, 0, "alpha", 0, 255); - if (rcdu->props.alpha == NULL) + if (!rcdu->props.alpha) return -ENOMEM; /* @@ -430,7 +430,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu) rcdu->props.colorkey = drm_property_create_range(rcdu->ddev, 0, "colorkey", 0, 0x01ff); - if (rcdu->props.colorkey == NULL) + if (!rcdu->props.colorkey) return -ENOMEM; return 0; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c index b373ad48ef5f..189e71b3d5d4 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c @@ -63,7 +63,7 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu, int ret; rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL); - if (rcon == NULL) + if (!rcon) return -ENOMEM; connector = &rcon->connector; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c index 12d22f3db1af..ab2576e5d700 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c @@ -253,7 +253,7 @@ int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu) for (i = 0; i < rcdu->info->num_lvds; ++i) { lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); - if (lvds == NULL) + if (!lvds) return -ENOMEM; lvds->dev = rcdu; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index 61833cc1c699..f48a990214ed 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -584,7
[PATCH 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init()
From: Markus Elfring Date: Tue, 24 Oct 2017 17:16:09 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 566d1a948c8f..d2c80cc9f8ee 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -377,10 +377,8 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) int ret; ret = of_graph_parse_endpoint(ep_node, &ep); - if (ret < 0) { - of_node_put(ep_node); - return ret; - } + if (ret < 0) + goto put_node; /* Find the output route corresponding to the port number. */ for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) { @@ -401,10 +399,8 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) /* Process the output pipeline. */ ret = rcar_du_encoders_init_one(rcdu, output, &ep); if (ret < 0) { - if (ret == -EPROBE_DEFER) { - of_node_put(ep_node); - return ret; - } + if (ret == -EPROBE_DEFER) + goto put_node; continue; } @@ -413,6 +409,10 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) } return num_encoders; + +put_node: + of_node_put(ep_node); + return ret; } static int rcar_du_properties_init(struct rcar_du_device *rcdu) -- 2.14.3
[PATCH 0/2] R-Car Display Unit: Fine-tuning for some function implementations
From: Markus Elfring Date: Tue, 24 Oct 2017 17:55:43 +0200 Two update suggestions were taken into account from static source code analysis. Markus Elfring (2): Use common error handling code in rcar_du_encoders_init() Adjust 14 checks for null pointers drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 22 +++--- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 6 +++--- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) -- 2.14.3
[PATCH] clk/Renesas: Delete an error message for a failed memory allocation in three functions
From: Markus Elfring Date: Mon, 25 Sep 2017 10:10:51 +0200 The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus fix affected source code places. Signed-off-by: Markus Elfring --- drivers/clk/renesas/clk-mstp.c | 5 + drivers/clk/renesas/clk-rcar-gen2.c | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c index 500a9e4e03c4..c944cc421e30 100644 --- a/drivers/clk/renesas/clk-mstp.c +++ b/drivers/clk/renesas/clk-mstp.c @@ -156,10 +156,8 @@ static struct clk * __init cpg_mstp_clock_register(const char *name, struct clk *clk; clock = kzalloc(sizeof(*clock), GFP_KERNEL); - if (!clock) { - pr_err("%s: failed to allocate MSTP clock.\n", __func__); + if (!clock) return ERR_PTR(-ENOMEM); - } init.name = name; init.ops = &cpg_mstp_clock_ops; @@ -196,7 +194,6 @@ static void __init cpg_mstp_clocks_init(struct device_node *np) if (group == NULL || clks == NULL) { kfree(group); kfree(clks); - pr_err("%s: failed to allocate group\n", __func__); return; } diff --git a/drivers/clk/renesas/clk-rcar-gen2.c b/drivers/clk/renesas/clk-rcar-gen2.c index 0b2e56d0d94b..d14cbe1ca29a 100644 --- a/drivers/clk/renesas/clk-rcar-gen2.c +++ b/drivers/clk/renesas/clk-rcar-gen2.c @@ -423,7 +423,6 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np) /* We're leaking memory on purpose, there's no point in cleaning * up as the system won't boot anyway. */ - pr_err("%s: failed to allocate cpg\n", __func__); return; } -- 2.14.1