Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4143946ybl; Tue, 20 Aug 2019 07:37:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZJ6TnxW4zdO5d5SR+TJdkx/2itlfoS7ZcDZEVdsii0qPyJCRkDEOualzDC/Wvy+LuA2bW X-Received: by 2002:a63:d002:: with SMTP id z2mr25601898pgf.364.1566311820556; Tue, 20 Aug 2019 07:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566311820; cv=none; d=google.com; s=arc-20160816; b=k4Xnd+KlsVplcuLk4mVahnpksxAjfQRDcCqI4nFGTtBBnxbu5eZHH2L/UYy0L47LYe Akhqyd8chGjMXZFNBEFNXT2SPc91Tu6XXTsiQvajBVUoGuH0h2DNDLqOIC2kvQZf0nnz 2rIDG06L3lls+w1Btpf6iL9ugIL7IrujtBZsGOvt/tHQfRU/8zLHX3a+5yJXoEzsAHEE G+ZTHrBVvkkUJbO8NuLONDxML60M/BjkrhVwy64D9EzcZWgRP/yspuv56Pvm9vboOyo5 YxKWKqp/JA/1JatHcLVN+82Zz9H3wsKm6Lv3MVY43KmNgLUWFQwBFLW8eAezi+k4fT+6 8TdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3UnWUmOV56EV05sRwCiWnOzQXplWcfdv01hfcG6/HJQ=; b=LicgeShYRjstgRaY+WX0+hki7WW+g0H+95Gx/Hd20EqkaJpkaNI62qUk+6z6GnEjdb udTc9iBoqW6akFybDVHEemipYLgXKnRym60csk3yn7TWB1ahcSNg3q/w8WET4ZmaNxoS zRfAUZg+KGHeqMQRKik8N5FUoK4lfvCqL/XVYWI9hp2N9uEKvonUeggIHCOnFYC6G1ZO DpyP4utJPJO+kbSnkcghtRSk+0XPrJ/PXOMwi3nH+tkRdoYSn0tiQxHSsY2IrsHGwOel 1ibnOwB4DTkSiaclYMkACSV7ZR9KSyzpAHbPq/785tcJCYFpHBbeGWLGIo8mg7rZj4aV SV/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b/BqYITV"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si12240757pgs.87.2019.08.20.07.36.45; Tue, 20 Aug 2019 07:37:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b/BqYITV"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730216AbfHTOdn (ORCPT + 99 others); Tue, 20 Aug 2019 10:33:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:38422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729762AbfHTOdn (ORCPT ); Tue, 20 Aug 2019 10:33:43 -0400 Received: from localhost (unknown [12.166.174.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3A0020673; Tue, 20 Aug 2019 14:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566311621; bh=ydinMJI9qM+u2naxA0AkkAYz3ega+bGQc59+jdnyhpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b/BqYITVeTNLr9pvvOB8aY0a+uUa5eesxprypPW4xpGSRyWSCpmoKV6BeXI7mvz55 yBHAn8fI4QQqHkTraJbeRDilFwgPSZcnKuSfx5IIg+H8PdWSSp8KqabI4nvZWr//W6 noxaXpwhd/4NLgiaQ4Ucx6amWwBtolwH6rnHMsZE= Date: Tue, 20 Aug 2019 07:33:41 -0700 From: Greg Kroah-Hartman To: zhangfei Cc: "zhangfei.gao@foxmail.com" , Arnd Bergmann , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, Kenneth Lee , Zaibo Xu , Zhou Wang Subject: Re: [PATCH 2/2] uacce: add uacce module Message-ID: <20190820143341.GB1536@kroah.com> References: <1565775265-21212-1-git-send-email-zhangfei.gao@linaro.org> <1565775265-21212-3-git-send-email-zhangfei.gao@linaro.org> <20190815142021.GE23267@kroah.com> <5d5a6f5b.1c69fb81.9d35e.5303SMTPIN_ADDED_BROKEN@mx.google.com> <20190819102413.GB2030@kroah.com> <0f7c6241-2028-76e7-0314-8b99cd353bd6@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0f7c6241-2028-76e7-0314-8b99cd353bd6@linaro.org> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 20, 2019 at 08:36:50PM +0800, zhangfei wrote: > Hi, Greg > > On 2019/8/19 下午6:24, Greg Kroah-Hartman wrote: > > > > > +static int uacce_create_chrdev(struct uacce *uacce) > > > > > +{ > > > > > + int ret; > > > > > + > > > > > + ret = idr_alloc(&uacce_idr, uacce, 0, 0, GFP_KERNEL); > > > > > + if (ret < 0) > > > > > + return ret; > > > > > + > > > > Shouldn't this function create the memory needed for this structure? > > > > You are relying ont he caller to do it for you, why? > > > I think you mean uacce structure here. > > > Yes, currently we count on caller to prepare uacce structure and call > > > uacce_register(uacce). > > > We still think this method is simpler, prepare uacce, register uacce. > > > And there are other system using the same method, like crypto > > > (crypto_register_acomp), nand, etc. > > crypto is not a subsystem to ever try to emulate :) > > > > You are creating a structure with a lifetime that you control, don't > > have someone else create your memory, that's almost never what you want > > to do. Most all driver subsystems create their own memory chunks for > > what they need to do, it's a much better pattern. > > > > Especially when you get into pointer lifetime issues... > OK, understand now, thanks for your patience. > will use this instead. > struct uacce_interface { >         char name[32]; >         unsigned int flags; >         struct uacce_ops *ops; > }; > struct uacce *uacce_register(struct device *dev, struct uacce_interface > *interface); What? Why do you need a structure? A pointer to the name and the ops should be all that is needed, right? And 'dev' here is a pointer to the parent, right? Might want to make that explicit in the name of the variable :) > > > > > + > > > > > +static int uacce_dev_match(struct device *dev, void *data) > > > > > +{ > > > > > + if (dev->parent == data) > > > > > + return -EBUSY; > > > > There should be in-kernel functions for this now, no need for you to > > > > roll your own. > > > Sorry, do not find this function. > > > Only find class_find_device, which still require match. > > It is in linux-next, look there... > > > Suppose you mean the funcs: device_match_name, > device_match_of_node,device_match_devt etc. > Here we need dev->parent, there still no such func. You should NEVER be matching on a parent. If so, your use of the driver model is wrong :) Remind me to really review the use of the driver core code in your next submission of this series please, I think it needs it. thanks, greg k-h