Re: [PATCH v2 1/1] fpga: dfl: afu: harden port enable logic

From: Xu Yilun
Date: Thu Sep 17 2020 - 21:28:39 EST


> > > /**
> > > * __afu_port_enable - enable a port by clear reset
> > > * @pdev: port platform device.
> > > @@ -32,7 +35,7 @@
> > > *
> > > * The caller needs to hold lock for protection.
> > > */
> > > -void __afu_port_enable(struct platform_device *pdev)
> > > +int __afu_port_enable(struct platform_device *pdev)
> > > {
> > > struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
> > > void __iomem *base;
> > > @@ -41,7 +44,7 @@ void __afu_port_enable(struct platform_device *pdev)
> > > WARN_ON(!pdata->disable_count);
> > >
> > > if (--pdata->disable_count != 0)
> > > - return;
> > > + return 0;
> > Is this really a success ? Maybe -EBUSY ?
> Seems like if it's severe enough for a warning you'd probably want to
> return an error.

This code is to handle the port enable/disable request from multiple
users. This is a voting mechanism, the port would not be physically
enabled if there is still an disable vote. The --diable_count != 0 works
for this purpose. So I think it should be OK here since the voting
mechanism is working as expected.

Thanks,
Yilun