[openib-general] [PATCH] Consolidate access to ib_agent_port_list

Hal Rosenstock halr at voltaire.com
Tue Oct 26 08:10:06 PDT 2004


Hi KK,

On Mon, 2004-10-25 at 16:11, Krishna Kumar wrote:
> This patch is similar to one for MAD that I sent some time earlier.
> 
> I could also have split the search routine into two, a get_by_dev
> and a get_by_agent, but I felt it was too cumbursome.

Looks pretty good. A couple of minor points:

> 
> Thanks,
> 
> - KK
> 
> --- ib_agent.c.org	2004-10-25 12:37:56.000000000 -0700
> +++ ib_agent.c	2004-10-25 12:42:55.000000000 -0700
> @@ -303,12 +303,52 @@
>  					      slid, mad, mad_response);
>  }
> 
> +static inline struct ib_agent_port_private *
> +__ib_get_agent_mad(struct ib_device *device, int port_num,
> +		   struct ib_mad_agent *mad_agent)
> +{
> +	struct ib_agent_port_private *entry;
> +
> +	BUG_ON(!spin_is_locked(&ib_agent_port_list_lock);

	BUG_ON(!spin_is_locked(&ib_agent_port_list_lock));


> @@ -729,21 +733,14 @@
> 
>  static int ib_agent_port_close(struct ib_device *device, int port_num)
>  {
> -	struct ib_agent_port_private *entry, *port_priv = NULL;
> +	struct ib_agent_port_private *port_priv;
>  	unsigned long flags;
> 
>  	spin_lock_irqsave(&ib_agent_port_list_lock, flags);
> -	list_for_each_entry(entry, &ib_agent_port_list, port_list) {
> -		if (entry->dr_smp_agent->device == device &&
> -		    entry->port_num == port_num) {
> -			port_priv = entry;
> -			break;
> -		}
> -	}
> -
> +	port_priv = __ib_get_agent_mad(NULL, 0, mad_agent);

I think this needs to be:
	port_priv = __ib_get_agent_mad(device, port_num, NULL);
If that's the case, I'm all set.

I also don't understand why the patching resulted in the need to do some
manual merging (as several hunks failed).

Thanks.

-- Hal




More information about the general mailing list