[ofa-general] Re: [PATCH] mlx4: display misc device information via sysfs under /sys/class/infiniband/mlx4_x, for ibstat and ibv_devinfo

Jack Morgenstein jackm at dev.mellanox.co.il
Tue Sep 18 01:43:07 PDT 2007


On Tuesday 18 September 2007 09:16, Michael S. Tsirkin wrote:
> > +static ssize_t show_hca(struct class_device *cdev, char *buf)
> > +{
> > +	struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
> > +	switch (dev->dev->pdev->device) {
> > +	case 0x6340:
> > +		return sprintf(buf, "MT25408\n");
> > +	case 0x634a:
> > +		return sprintf(buf, "MT25418\n");
> > +	case 0x6354:
> > +		return sprintf(buf, "MT25428\n");
> > +	case 0x6732:
> > +		return sprintf(buf, "MT26418\n");
> > +	case 0x673c:
> > +		return sprintf(buf, "MT26428\n");
> > +	default:
> > +		return sprintf(buf, "unknown\n");
> > +	}
> > +}
> 
> How about just
> 
> static ssize_t show_hca(struct class_device *cdev, char *buf)
> {
> 	struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
> 	return sprintf(buf, "MT%d\n", dev->dev->pdev->device);
> }
> 
Looks OK.  Don't need the "default" case, since the kernel will only invoke the mlx4 driver
for the device-id's it registers for.
(see static struct pci_device_id mlx4_pci_table[] in file drivers/net/mlx4/main.c)

- Jack



More information about the general mailing list