From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbdJTHGP (ORCPT ); Fri, 20 Oct 2017 03:06:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:42505 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbdJTHGO (ORCPT ); Fri, 20 Oct 2017 03:06:14 -0400 Date: Fri, 20 Oct 2017 09:06:13 +0200 Message-ID: From: Takashi Iwai To: Vinod Koul Cc: ALSA , Charles Keepax , patches.audio@intel.com, Greg Kroah-Hartman , plai@codeaurora.org, LKML , Pierre , Sagar Dharia , Mark , srinivas.kandagatla@linaro.org, Shreyas NC , Sanyog Kale , Sudheer Papothi , alan@linux.intel.com Subject: Re: [alsa-devel] [PATCH 06/14] soundwire: Add IO transfer In-Reply-To: <20171020053006.GJ30097@localhost> References: <1508382211-3154-1-git-send-email-vinod.koul@intel.com> <1508382211-3154-7-git-send-email-vinod.koul@intel.com> <20171020053006.GJ30097@localhost> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Oct 2017 07:30:06 +0200, Vinod Koul wrote: > > On Thu, Oct 19, 2017 at 11:13:48AM +0200, Takashi Iwai wrote: > > On Thu, 19 Oct 2017 05:03:22 +0200, > > Vinod Koul wrote: > > > > > > +/** > > > + * sdw_transfer: Synchronous transfer message to a SDW Slave device > > > + * > > > + * @bus: SDW bus > > > + * @slave: SDW Slave > > > + * @msg: SDW message to be xfered > > > + */ > > > +int sdw_transfer(struct sdw_bus *bus, struct sdw_slave *slave, > > > + struct sdw_msg *msg) > > > +{ > > > + bool page; > > > + int ret; > > > + > > > + mutex_lock(&bus->msg_lock); > > > + > > > + page = sdw_get_page(slave, msg); > > > + > > > + ret = do_transfer(bus, msg, page); > > > + if (ret != 0 && ret != -ENODATA) { > > > + dev_err(bus->dev, "trf on Slave %d failed:%d\n", > > > + msg->dev_num, ret); > > > + goto error; > > > + } > > > + > > > + if (page) > > > + ret = sdw_reset_page(bus, msg->dev_num); > > > + > > > +error: > > > + mutex_unlock(&bus->msg_lock); > > > + > > > + return ret; > > > > So the logic here is that when -ENODATA is returned and page is false, > > this function should return -ENODATA to the caller, but when page > > is set, it returns 0? > > Sorry no. do_transfer can succced (0) or in some case where Slaves didn't > care for return error (ENODATA), or other errors. > No ENODATA can be error depending on message sent so we dont treat this as > failure and let caller decide. > > In case of errors (others) we don't need to reset page and we bail out Well, the question is the handling of ENODATA. Whether the function returns 0 or -ENODATA depends on page flag. If page flag is true, -ENODATA is cleared. My question was whether this behavior is intended or not. If -ENODATA should be returned whenever it gets that from do_transfer(), the code has a potential bug there. Takashi