Jonathan Cameron wrote: > On Thu, 15 May 2025 22:47:30 -0700 > Dan Williams <dan.j.williams@xxxxxxxxx> wrote: > > > Exercise common setup and teardown flows for a sample platform TSM > > driver that implements the TSM 'connect' and 'disconnect' flows. > > > > This is both a template for platform specific implementations and a > > simple integration test for the PCI core infrastructure + ABI. > > > > Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> > > Cc: Lukas Wunner <lukas@xxxxxxxxx> > > Cc: Samuel Ortiz <sameo@xxxxxxxxxxxx> > > Cc: Alexey Kardashevskiy <aik@xxxxxxx> > > Cc: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx> > > Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> > Trivial comment inline. > > > index 7a8d33dc54c6..aa852ac1c16d 100644 > > --- a/samples/devsec/tsm.c > > +++ b/samples/devsec/tsm.c > > > /* > > * Reference consumer for a TSM driver "connect" operation callback. The > > * low-level TSM driver understands details about the platform the PCI > > @@ -74,11 +79,81 @@ static void devsec_tsm_pci_remove(struct pci_tsm *tsm) > > */ > > static int devsec_tsm_connect(struct pci_dev *pdev) > > { > > - return -ENXIO; > > + struct pci_dev *rp = pcie_find_root_port(pdev); > > + struct pci_ide *ide; > > + int rc, stream_id; > > + > > + stream_id = > > + find_first_zero_bit(devsec_stream_ids, NR_TSM_STREAMS); > > Ugly and it's under 80 chars on one line. Just a missed clang-format, fixed. > > > > + if (stream_id == NR_TSM_STREAMS) > > + return -EBUSY; > > > > > static void devsec_tsm_disconnect(struct pci_dev *pdev) > > { > > + struct pci_dev *rp = pcie_find_root_port(pdev); > > + struct pci_ide *ide; > > + int i; > > + > > + for_each_set_bit(i, devsec_stream_ids, NR_TSM_STREAMS) > > + if (devsec_streams[i]->pdev == pdev) > > + break; > > + > > + if (i >= NR_TSM_STREAMS) > == NR_TSM_STREAMS > not that it really matters but it can never be greater. I does not matter in practice but if the valid values are "< size" then the invalid values are ">= size".