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

Michael S. Tsirkin mst at dev.mellanox.co.il
Tue Sep 18 00:16:58 PDT 2007


> +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);
}

-- 
MST



More information about the general mailing list