Re: [EXT] Re: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

From: Michal Schmidt
Date: Wed Dec 06 2023 - 09:21:04 EST


On Wed, Dec 6, 2023 at 3:12 PM Shinas Rasheed <srasheed@xxxxxxxxxxx> wrote:
>
> Hi Michal
>
> > -----Original Message-----
> > From: Michal Schmidt <mschmidt@xxxxxxxxxx>
> > Sent: Wednesday, December 6, 2023 7:28 PM
> > To: Shinas Rasheed <srasheed@xxxxxxxxxxx>
> > > pci_read_config_byte(pdev, (pos + 8), &status);
> > > dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
> > > - return status;
> > > +#define FW_STATUS_READY 1ULL
> > > + return (status == FW_STATUS_READY) ? true : false;
> >
> > "status == FW_STATUS_READY" is already the bool value you want. You
> > don't need to use the ternary operator here.
> >
>
> In some abnormal cases, the driver can read the firmware ready status as 2. Hence this need for explicitly checking if status
> is indeed 1 or not. If it is 2, the function should understand it as the firmware is not ready. (It has to be strictly 1 for the driver
> to understand it as ready)

I'm not disputing that. I'm saying that this:
return (status == FW_STATUS_READY) ? true : false;
is equivalent to:
return status == FW_STATUS_READY;

Michal