From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5533EC433B4 for ; Thu, 29 Apr 2021 07:30:26 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 782F36143E for ; Thu, 29 Apr 2021 07:30:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 782F36143E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kroah.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1lc17Q-0002cu-Lk; Thu, 29 Apr 2021 03:29:52 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lc17M-0002aq-8O for kernelnewbies@kernelnewbies.org; Thu, 29 Apr 2021 03:29:48 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 05C7B13BB; Thu, 29 Apr 2021 03:29:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 29 Apr 2021 03:29:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=KNiT5YSNr1iEOxsKHnOcaGbgM43 KOw36aKlxViu9ATw=; b=klXXWiTnrr3Y6c6frZF86JTDYNJgFsdDGKUfck9u3le JfTJ72FG5DV1OeacXz42wVvwnz4XPnUE/9ECt+OLadThE1HXFAuf5HXh35wbRAum MWZcZrT3wPPfJDPv0TRBYZn1N6tYX9QIK7iyIPs5dZXmyMS1mxQzUIudZwen2AYq ZP0PBtaPmfeDDIJiMIxouPCUzkkZAHxsAtkcieCeq8mr59DwrqcPdseddposF8/q GgnEMWtOtOUL2von1RFo7fDHVm2uYVlL9JzzZId5Ycjkj5I5K+P/IAJEu/OeyVPd qK3OPpMAA16qrV7bMO2Gox7p89oV6UdUT0JTRLMogqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=KNiT5Y SNr1iEOxsKHnOcaGbgM43KOw36aKlxViu9ATw=; b=YgRXVEx5yywF94R07l2kOK ulSbPFqSu1TD3Qbo21HeuWFf/wFujvOHbF+5UWLEdKIhNpziU0f0NSWOAYa85fS5 S6HUV0Bu2IrLPTKXJXcSRDVsrghPzHqJMZE6VwPelWAOtGASGQrV1HnacxR/xGQo vjs1Bdz+rxSA4A7f4dKQMUJBBNRSF6g0jOq84554Xcq/3BGonWQ1WV0sUyRo9ose NybhdDfund1zB8jJDEQcj448AWKvwyysfwkbo/LfF1UR3aEPEOz+dVkIAF2RcSwm 0GoRTbQrolmqpJH9A5cspfx6Ns7wQKpTvQJ6gajA3ygq9fOlOlm0EenoWLadlGGA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddvfedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehttd ertddttddvnecuhfhrohhmpedkifhrvghgucfmjfdkuceoghhrvghgsehkrhhorghhrdgt ohhmqeenucggtffrrghtthgvrhhnpeeihfeghefghfevveekueeiieeghedvhfeludevgf eujedvleeufeegtdduleeufeenucfkphepkeefrdekiedrjeegrdeigeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhh drtghomh X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Apr 2021 03:29:41 -0400 (EDT) Date: Thu, 29 Apr 2021 09:29:38 +0200 From: 'Greg KH' To: ckim@etri.re.kr Subject: Re: can't find device_create funtion in a driver containing cdev (habanalabs) Message-ID: References: <014d01d73c34$df6dcd00$9e496700$@etri.re.kr> <018201d73c92$7153fb60$53fbf220$@etri.re.kr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <018201d73c92$7153fb60$53fbf220$@etri.re.kr> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Thu, Apr 29, 2021 at 09:56:09AM +0900, ckim@etri.re.kr wrote: > Hi, Greg KH, > > To me cdev_device_add seems to be calling only cdev_add(below). > In this case since dev->devt already holds dev_t value ("hl%d"), it just > sets cdev_set_parent and cdev_add. > > int cdev_device_add(struct cdev *cdev, struct device *dev) > { > int rc = 0; > > if (dev->devt) { > cdev_set_parent(cdev, &dev->kobj); > > rc = cdev_add(cdev, dev->devt, 1); > if (rc) > return rc; > } > > rc = device_add(dev); Right here is the line you are looking for. device_create() is a wrapper around a call to device_initialize() and device_add(). To use cdev_device_add() you have to have already called device_initialize() which the habannalabs code already did. Only on device_add() is the device really "added" to the driver core, and the uevents are sent out and lots of other stuff happens. device_create() wraps a lot of housekeeping logic up into a simpler call if your driver doesn't need that level of flexibility, but there is no requirement to call only it at all. Hope this helps, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies