mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	pwm: pxa: Improve using dev_err_probe()
Add a message to the error path of devm_clk_get() and simplify the error path of devm_pwmchip_add() while improving the error message en passant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/20250313072855.3360076-2-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
This commit is contained in:
		
							parent
							
								
									2b62c89448
								
							
						
					
					
						commit
						df08fff8ad
					
				
					 1 changed files with 8 additions and 10 deletions
				
			
		| 
						 | 
					@ -160,24 +160,24 @@ static int pwm_probe(struct platform_device *pdev)
 | 
				
			||||||
	const struct platform_device_id *id = platform_get_device_id(pdev);
 | 
						const struct platform_device_id *id = platform_get_device_id(pdev);
 | 
				
			||||||
	struct pwm_chip *chip;
 | 
						struct pwm_chip *chip;
 | 
				
			||||||
	struct pxa_pwm_chip *pc;
 | 
						struct pxa_pwm_chip *pc;
 | 
				
			||||||
 | 
						struct device *dev = &pdev->dev;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (IS_ENABLED(CONFIG_OF) && id == NULL)
 | 
						if (IS_ENABLED(CONFIG_OF) && id == NULL)
 | 
				
			||||||
		id = of_device_get_match_data(&pdev->dev);
 | 
							id = of_device_get_match_data(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (id == NULL)
 | 
						if (id == NULL)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	chip = devm_pwmchip_alloc(&pdev->dev,
 | 
						chip = devm_pwmchip_alloc(dev, (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1,
 | 
				
			||||||
				  (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1,
 | 
					 | 
				
			||||||
				  sizeof(*pc));
 | 
									  sizeof(*pc));
 | 
				
			||||||
	if (IS_ERR(chip))
 | 
						if (IS_ERR(chip))
 | 
				
			||||||
		return PTR_ERR(chip);
 | 
							return PTR_ERR(chip);
 | 
				
			||||||
	pc = to_pxa_pwm_chip(chip);
 | 
						pc = to_pxa_pwm_chip(chip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pc->clk = devm_clk_get(&pdev->dev, NULL);
 | 
						pc->clk = devm_clk_get(dev, NULL);
 | 
				
			||||||
	if (IS_ERR(pc->clk))
 | 
						if (IS_ERR(pc->clk))
 | 
				
			||||||
		return PTR_ERR(pc->clk);
 | 
							return dev_err_probe(dev, PTR_ERR(pc->clk), "Failed to get clock\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	chip->ops = &pxa_pwm_ops;
 | 
						chip->ops = &pxa_pwm_ops;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,11 +188,9 @@ static int pwm_probe(struct platform_device *pdev)
 | 
				
			||||||
	if (IS_ERR(pc->mmio_base))
 | 
						if (IS_ERR(pc->mmio_base))
 | 
				
			||||||
		return PTR_ERR(pc->mmio_base);
 | 
							return PTR_ERR(pc->mmio_base);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = devm_pwmchip_add(&pdev->dev, chip);
 | 
						ret = devm_pwmchip_add(dev, chip);
 | 
				
			||||||
	if (ret < 0) {
 | 
						if (ret < 0)
 | 
				
			||||||
		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
 | 
							return dev_err_probe(dev, ret, "pwmchip_add() failed\n");
 | 
				
			||||||
		return ret;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue