mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-10 07:50:04 +00:00
pwm: dwc: Move memory allocation to own function
In preparation for adding other bus support, move the allocation of the PWM structure out of the main driver code. Signed-off-by: Ben Dooks <ben.dooks@sifive.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
f7c843d6d7
commit
a357d1493f
@ -198,13 +198,29 @@ static const struct pwm_ops dwc_pwm_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct dwc_pwm *dwc_pwm_alloc(struct device *dev)
|
||||
{
|
||||
struct dwc_pwm *dwc;
|
||||
|
||||
dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
|
||||
if (!dwc)
|
||||
return NULL;
|
||||
|
||||
dwc->chip.dev = dev;
|
||||
dwc->chip.ops = &dwc_pwm_ops;
|
||||
dwc->chip.npwm = DWC_TIMERS_TOTAL;
|
||||
|
||||
dev_set_drvdata(dev, dwc);
|
||||
return dwc;
|
||||
}
|
||||
|
||||
static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
|
||||
{
|
||||
struct device *dev = &pci->dev;
|
||||
struct dwc_pwm *dwc;
|
||||
int ret;
|
||||
|
||||
dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
|
||||
dwc = dwc_pwm_alloc(dev);
|
||||
if (!dwc)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -228,12 +244,6 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pci_set_drvdata(pci, dwc);
|
||||
|
||||
dwc->chip.dev = dev;
|
||||
dwc->chip.ops = &dwc_pwm_ops;
|
||||
dwc->chip.npwm = DWC_TIMERS_TOTAL;
|
||||
|
||||
ret = pwmchip_add(&dwc->chip);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user