Re: [PATCH v3 7/7] rtc: Add Nuvoton NCT6694 RTC support

Ming Yu
2024-12-23T01:51:08Z

Dear Alexandre,

Thank you for your comments,

Alexandre Belloni <alexandre.belloni@bootlin.com> 於 2024年12月16日 週一 下午6:42寫道：
>
> On 10/12/2024 18:45:24+0800, Ming Yu wrote:
> > +static int nct6694_rtc_probe(struct platform_device *pdev)
> > +{
> > + struct nct6694_rtc_data *data;
> > + struct nct6694 *nct6694 = dev_get_drvdata(pdev->dev.parent);
> > + int ret, irq;
> > +
> > + irq = irq_create_mapping(nct6694->domain, NCT6694_IRQ_RTC);
> > + if (!irq)
> > + return -EINVAL;
> > +
> > + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> > + if (!data)
> > + return -ENOMEM;
> > +
> > + data->xmit_buf = devm_kcalloc(&pdev->dev, NCT6694_MAX_PACKET_SZ,
> > + sizeof(unsigned char), GFP_KERNEL);
> > + if (!data->xmit_buf)
> > + return -ENOMEM;
> > +
> > + data->rtc = devm_rtc_allocate_device(&pdev->dev);
> > + if (IS_ERR(data->rtc))
> > + return PTR_ERR(data->rtc);
> > +
> > + data->nct6694 = nct6694;
> > + data->rtc->ops = &nct6694_rtc_ops;
> > + data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> > + data->rtc->range_max = RTC_TIMESTAMP_END_2099;
> > +
> > + mutex_init(&data->lock);
>
> You should use rtc_lock/rtc_unlock instead of having your own lock. The
> core will take and release the lock appropriately before calling the
> rtc_ops so you only have to do it in the irq handler.
>

Understood. I will make the modifications in the next patch.

> > +
> > + device_set_wakeup_capable(&pdev->dev, 1);
>
> This will cause a memory leak later on, see the discussion here:
>
> https://lore.kernel.org/linux-rtc/a88475b6-08bf-4c7c-ad63-efd1f29307e3@pf.is.s.u-tokyo.ac.jp/T/#mf51fdce6036efa3ea12fe75bd5126d4ac0c6813e
>

Okay! I will drop it and add device_init_wakeup() in the next patch.

Best regards,
Ming