Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp316734pxb; Thu, 17 Feb 2022 04:57:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBC661o1IJp1FnS8gmoSpTcLkETafubxUaphiGyjQt3Dzm36F74sBRTvFLdo+bQpOmViWS X-Received: by 2002:a63:5a0e:0:b0:372:ad75:9b66 with SMTP id o14-20020a635a0e000000b00372ad759b66mr2350087pgb.78.1645102667388; Thu, 17 Feb 2022 04:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645102667; cv=none; d=google.com; s=arc-20160816; b=ISO0nxoVuV1a8OPofd2g9hdXxYIEsgW/AlH66k0AajMe0okOe3oGMS9I4/HbyVaI0z Z/PuxvuIZ85J8Z/+V1EM/L2qWP0CZJ35yrIX10fwKeRy6G9aCkIEiHhmjGsPh5GTSoWt VscZFWT+lhVZuvsiWC8BzQsZgWXE3gkhbVFN8TqcO/2b9Wk7f6GMPetnZ7jyYNgxF6vw J458CxBLfpVUwtgyOwEoP1Jh/Shxyvvu3YLkcRg7IVp7bA3bbqq5jRpRepichSqpKduX wKgu+7Hngx9qAOSeMVBA0iSNkoPRdM3nELgUBXRZjpwzVzw/7x+VtgQJumHFARuL6Ns9 sl6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mpkGaHYhzDT/ywTqBANboh+oafdc1Ua2ViLPT/QoCeg=; b=Q7ekd82CnE4LUUxL2xPrE0C9ChQIPxCNk+CgKThG3z5FNkxN3JKB0iHPBdtiNTtFLu OZKRdQDWfUadbT1kT9bvytbVxz0iWrYxh1Li8WjrASLU50PBX1J5PF5dPf728LXDR+RM k32dibS1nQ1KDPUFGo55QeI9iZLeMhi8UwaaXjUkN/pUlkmLfJadjJCWy4WgSQfiMS0C E5EtFAoNkptZMjLL+bR/LvvODevo3ul2T9h4gs5t88BEkfre6hWDyvtklDzLzS557jXn bI5ajY04klC5rpXerY+OAIR0bZxn0cMnjAGJgEhyNKEKLcFlWdNbVUlvXeZ/nJ/Q07rx q5CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eaq+/s/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19si8080804pgo.191.2022.02.17.04.57.30; Thu, 17 Feb 2022 04:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eaq+/s/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235637AbiBQMFD (ORCPT + 99 others); Thu, 17 Feb 2022 07:05:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiBQMFD (ORCPT ); Thu, 17 Feb 2022 07:05:03 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086B362D3 for ; Thu, 17 Feb 2022 04:04:46 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so5183133pjh.3 for ; Thu, 17 Feb 2022 04:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mpkGaHYhzDT/ywTqBANboh+oafdc1Ua2ViLPT/QoCeg=; b=eaq+/s/imLxDnW1yvcbqmJSkDOtbiRD9g5qyu4gLTnTKG6y22OTiQ5PEVi8uJ/iPZi nKNJbuG5j2sqnSldTwlrbJv1XSXNIjvx8dOydio2AYa21EvypE5oNSDqQtT4r5PkaYLd jpQojSfKwHlR5BwPE0G65igiyIzUXwBTsV/ky9f1opwVe17pTyqGj6gYWExRQ2b2+SVL kg4AZ22HB4ZLnbozYKCCI+xzdPTTmHMQiM0KOTOll8DnTNYMv/avIw4E533gOYTGLlnK BkFADZzt/uHWqkIkKBwIWWijHfTLpTHs0GLOjP0/GJ/5Nqu4nhKMgkV3zaGMMoy/+MHv 2gqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mpkGaHYhzDT/ywTqBANboh+oafdc1Ua2ViLPT/QoCeg=; b=IF0U7iDuv8wEJYsyegtjxI0QNmDklf3IigDC9qmyASMUDssPmlZ1kMXyB2hp+wnJbT raIxknBOOlDXgfVwfe8twzXKVAg9JEtWNizll9JPxsQJPomQzogquvpFl7zuI7vWqpHr W+GPZejVInEFBENaoh5mjAigMdxUofKOA1ZXQzM5OM+4CkZLLcYm87tJJHjVuKdbUouc 5m5p3lhGsHxkF3el7cnNMlpV+Qjmw6pL+xmhfIBTjyhlvosVneUqZLKvxrWZzzK/PPCS qRYPFbghY4z2+xsU1OzYQkFhQdFHhvL4exc+COPrirogQgDwcbHKJC5APvjwuxMku5SY KdBQ== X-Gm-Message-State: AOAM530vxgpDwACQ5R5hHWxQM78rxV6I1xjBppUC2HrlcgFxQyp8jzRs +GDnuc1Lf7oKF7tbAoBQb4Q7u2ovxiPMq74= X-Received: by 2002:a17:902:bb89:b0:14d:85a7:6eea with SMTP id m9-20020a170902bb8900b0014d85a76eeamr2506343pls.158.1645099485450; Thu, 17 Feb 2022 04:04:45 -0800 (PST) Received: from workstation ([117.193.211.41]) by smtp.gmail.com with ESMTPSA id mv17sm1336990pjb.14.2022.02.17.04.04.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Feb 2022 04:04:44 -0800 (PST) Date: Thu, 17 Feb 2022 17:34:39 +0530 From: Manivannan Sadhasivam To: Alex Elder Cc: mhi@lists.linux.dev, quic_hemantk@quicinc.com, quic_bbhatt@quicinc.com, quic_jhugo@quicinc.com, vinod.koul@linaro.org, bjorn.andersson@linaro.org, dmitry.baryshkov@linaro.org, quic_vbadigan@quicinc.com, quic_cang@quicinc.com, quic_skananth@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 10/25] bus: mhi: ep: Add support for creating and destroying MHI EP devices Message-ID: <20220217120439.GC11964@workstation> References: <20220212182117.49438-1-manivannan.sadhasivam@linaro.org> <20220212182117.49438-11-manivannan.sadhasivam@linaro.org> <1cdd8e0c-85d7-dd91-a6f1-1390e7854350@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1cdd8e0c-85d7-dd91-a6f1-1390e7854350@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 15, 2022 at 02:02:57PM -0600, Alex Elder wrote: [...] > > + > > + mhi_dev = mhi_ep_alloc_device(mhi_cntrl, MHI_DEVICE_XFER); > > + if (IS_ERR(mhi_dev)) > > + return PTR_ERR(mhi_dev); > > It looks like the only possible error is no memory, so you could > just have mhi_ep_alloc_device() return NULL. > I think returning the actual error is more safe as we may end up adding more stuff into this function in the future. > > + > > + /* Configure primary channel */ > > + mhi_dev->ul_chan = mhi_chan; > > + get_device(&mhi_dev->dev); > > + mhi_chan->mhi_dev = mhi_dev; > > + > > + /* Configure secondary channel as well */ > > + mhi_chan++; > > + mhi_dev->dl_chan = mhi_chan; > > + get_device(&mhi_dev->dev); > > + mhi_chan->mhi_dev = mhi_dev; > > + > > + /* Channel name is same for both UL and DL */ > > + mhi_dev->name = mhi_chan->name; > > + dev_set_name(&mhi_dev->dev, "%s_%s", > > + dev_name(&mhi_cntrl->mhi_dev->dev), > > + mhi_dev->name); > > + > > + ret = device_add(&mhi_dev->dev); > > + if (ret) > > + put_device(&mhi_dev->dev); > > + > > + return ret; > > +} > > + > > +static int mhi_ep_destroy_device(struct device *dev, void *data) > > +{ > > + struct mhi_ep_device *mhi_dev; > > + struct mhi_ep_cntrl *mhi_cntrl; > > + struct mhi_ep_chan *ul_chan, *dl_chan; > > + > > + if (dev->bus != &mhi_ep_bus_type) > > + return 0; > > + > > + mhi_dev = to_mhi_ep_device(dev); > > + mhi_cntrl = mhi_dev->mhi_cntrl; > > + > > + /* Only destroy devices created for channels */ > > + if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER) > > + return 0; > > + > > + ul_chan = mhi_dev->ul_chan; > > + dl_chan = mhi_dev->dl_chan; > > Aren't they required to supply *both* channels? Or maybe > it's just required that there are transfer callback functions > for both channels. Anyway, no need to check for null, because > the creation function guarantees they're both non-null I think. > mhi_ep_destroy_device() will be called for each device separately. So we must check for NULL. Thanks, Mani