[ofa-general] Re: [PATCH] ibsim/umad2sim.c: Eliminate unneeded umad2sim_dev num

Sasha Khapyorsky sashak at voltaire.com
Fri Feb 27 01:08:45 PST 2009


Hi Hal,

On 12:44 Thu 19 Feb     , Hal Rosenstock wrote:
> 
> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
> ---
> diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c
> index e13e30a..aaa6260 100644
> --- a/umad2sim/umad2sim.c
> +++ b/umad2sim/umad2sim.c
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
> + * Copyright (c) 2009 HNR Consulting. All rights reserved.
>   *
>   * This file is part of ibsim.
>   *
> @@ -77,7 +78,6 @@ struct ib_user_mad_reg_req {
>  
>  struct umad2sim_dev {
>  	int fd;
> -	unsigned num;

Wouldn't it be useful when more than one CA/host ports will be supported
using umad2sim?

Sasha

>  	char name[32];
>  	uint8_t port;
>  	struct sim_client sim_client;
> @@ -351,15 +351,13 @@ static int dev_sysfs_create(struct umad2sim_dev *dev)
>  	*str = '\0';
>  
>  	/* /sys/class/infiniband_mad/umad0/ */
> -	snprintf(path, sizeof(path), "%s/umad%u", sysfs_infiniband_mad_dir,
> -		 dev->num);
> +	snprintf(path, sizeof(path), "%s/umad%u", sysfs_infiniband_mad_dir, 0);
>  	make_path(path);
>  	file_printf(path, SYS_IB_MAD_DEV, "%s\n", dev->name);
>  	file_printf(path, SYS_IB_MAD_PORT, "%d\n", dev->port);
>  
>  	/* /sys/class/infiniband_mad/issm0/ */
> -	snprintf(path, sizeof(path), "%s/issm%u", sysfs_infiniband_mad_dir,
> -		 dev->num);
> +	snprintf(path, sizeof(path), "%s/issm%u", sysfs_infiniband_mad_dir, 0);
>  	make_path(path);
>  	file_printf(path, SYS_IB_MAD_DEV, "%s\n", dev->name);
>  	file_printf(path, SYS_IB_MAD_PORT, "%d\n", dev->port);
> @@ -546,7 +544,7 @@ static int umad2sim_ioctl(struct umad2sim_dev *dev, unsigned long request,
>  	return -1;
>  }
>  
> -static struct umad2sim_dev *umad2sim_dev_create(unsigned num, const char *name)
> +static struct umad2sim_dev *umad2sim_dev_create(const char *name)
>  {
>  	struct umad2sim_dev *dev;
>  	unsigned i;
> @@ -558,7 +556,6 @@ static struct umad2sim_dev *umad2sim_dev_create(unsigned num, const char *name)
>  		return NULL;
>  	memset(dev, 0, sizeof(*dev));
>  
> -	dev->num = num;
>  	strncpy(dev->name, name, sizeof(dev->name) - 1);
>  
>  	if (sim_client_init(&dev->sim_client) < 0)
> @@ -574,9 +571,9 @@ static struct umad2sim_dev *umad2sim_dev_create(unsigned num, const char *name)
>  	dev_sysfs_create(dev);
>  
>  	snprintf(dev->umad_path, sizeof(dev->umad_path), "%s/%s%u",
> -		 umad_dev_dir, "umad", num);
> +		 umad_dev_dir, "umad", 0);
>  	snprintf(dev->issm_path, sizeof(dev->issm_path), "%s/%s%u",
> -		 umad_dev_dir, "issm", num);
> +		 umad_dev_dir, "issm", 0);
>  
>  	return dev;
>  
> @@ -646,7 +643,7 @@ static void umad2sim_init(void)
>  	DEBUG("umad2sim_init...\n");
>  	snprintf(umad2sim_sysfs_prefix, sizeof(umad2sim_sysfs_prefix),
>  		 "./sys-%d", getpid());
> -	devices[0] = umad2sim_dev_create(0, "ibsim0");
> +	devices[0] = umad2sim_dev_create("ibsim0");
>  	if (!devices[0]) {
>  		ERROR("cannot init umad2sim. Exit.\n");
>  		exit(-1);



More information about the general mailing list