From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936217AbdKPRFj (ORCPT ); Thu, 16 Nov 2017 12:05:39 -0500 Received: from mga01.intel.com ([192.55.52.88]:64976 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758873AbdKPRFc (ORCPT ); Thu, 16 Nov 2017 12:05:32 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,404,1505804400"; d="scan'208";a="177012833" Date: Thu, 16 Nov 2017 22:38:50 +0530 From: Vinod Koul To: Srinivas Kandagatla Cc: Greg Kroah-Hartman , LKML , ALSA , Mark , Takashi , Pierre , Sanyog Kale , Shreyas NC , patches.audio@intel.com, alan@linux.intel.com, Charles Keepax , Sagar Dharia , plai@codeaurora.org, Sudheer Papothi Subject: Re: [PATCH v2 08/14] soundwire: Add Slave status handling helpers Message-ID: <20171116170850.GF3187@localhost> References: <1510314556-13002-1-git-send-email-vinod.koul@intel.com> <1510314556-13002-9-git-send-email-vinod.koul@intel.com> <06a1bcfc-eeca-b3ec-1d74-e6ac9cadce53@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <06a1bcfc-eeca-b3ec-1d74-e6ac9cadce53@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 16, 2017 at 04:05:29PM +0000, Srinivas Kandagatla wrote: > > Minor Comment! > > On 10/11/17 11:49, Vinod Koul wrote: > >From: Sanyog Kale > > > >SoundWire Slaves report status to bus. Add helpers to handle > >the status changes. > > > >Signed-off-by: Hardik T Shah > >Signed-off-by: Sanyog Kale > >Signed-off-by: Vinod Koul > >--- > > >+static int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) > >+{ > >+ > >+ if ((slave->id.unique_id != id.unique_id) || > >+ (slave->id.mfg_id != id.mfg_id) || > >+ (slave->id.part_id != id.part_id) || > >+ (slave->id.class_id != id.class_id)) > >+ return -ENODEV; > >+ > >+ return 0; > >+} > >+ > >+/* called with bus_lock held */ > >+static int sdw_get_device_num(struct sdw_slave *slave) > >+{ > If we use ida we would not need this function. Not really, find_first_zero_bit and set_bit will be replaced by get_ida() the bound check will still be required as we have finite set of ids to work with. Nevertheless I will check if it helps in this case and move if helpful. > >+ int bit; > >+ > >+ bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES); > >+ if (bit == SDW_MAX_DEVICES) { > >+ bit = -ENODEV; > >+ goto err; > >+ } > >+ > >+ /* > >+ * Do not update dev_num in Slave data structure here, > >+ * Update once program dev_num is successful > >+ */ > >+ set_bit(bit, slave->bus->assigned); > >+ > >+err: > >+ return bit; > >+} -- ~Vinod