From owner-freebsd-hackers@freebsd.org Thu Jun 4 18:31:36 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FAA532C24C; Thu, 4 Jun 2020 18:31:36 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49dDrR2Vkpz4Vcw; Thu, 4 Jun 2020 18:31:35 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wr1-x42f.google.com with SMTP id y17so7184216wrn.11; Thu, 04 Jun 2020 11:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4w0fxpur3RWk2sa3+8JZgKq98Ncv47d1Qg1yZnzJfus=; b=AvNI+YLKMCrsAO9NWaQ7D2Kre26+ITgEPrGmoZ9a0endBxUtFWZ7gCqF+Xp2T/U0nf n3pkQfpUREnZtFhdkchJxkcUl1iJciyK08NKDTWERQT6pw84xJq/JmFhskvEO7C8fdV8 uQPTb0VAynPnsNGREn6TOZ4AsUEeih5LmzHGHLTpniXMGz2F2GGJpTa76TSPXnzgivjy 66EIE6VwIqkmbxh4VSz1hpJOX/RdVqlL9a2FdXaeJbxQWuzdgz2baCdz8EIz3dgjQHJf kdhDGiowlUSjA3d6GBhSBHPaTMsnBriH6VeebxiwthbqKRiW1xuQXLo3X9lu0wDdhTS9 nDBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4w0fxpur3RWk2sa3+8JZgKq98Ncv47d1Qg1yZnzJfus=; b=VG0kwMy4fxExWCuB28UFPPRp+EStR0lmyFkaWHGeaF66hH3vdiQBqCXQjK3mjTxGUV AbrqqQw1yrGxEMdSx+rcklsJgb//GtYaM3TQJYaK1owH7wUoSlJaS5kU5483Ci7tBzoT 4CJRoeTD78csLgBAxfnMf6+FKEeumG+4TdbVhQtB4nzCIQDOQ9C2izZiuiZbjggD3i/U g76PldEr5lvqN1icQDYThVgAjpLF6u6WTHvAP4rwOK5jq0l414cPqNugoYDSAN+vHIu9 adQN97XM2yRk8WJoSFmVBZUc/EOaa602TFT1Cd5qLpmu26MArm3dXkFZC1YJEYv/JF7Z yXCQ== X-Gm-Message-State: AOAM532qmQjShx68QvpV74dsw1tPnt76XtCwU4UQqGOHx6SAf2Y4ghA2 9XCV64MPTLfW2ZyHPIJgMuSlg/sxWj85eZ6E+L8xHt/M X-Google-Smtp-Source: ABdhPJxLFPUz5mqiLffZWDnFdAce7HZd9Dfe00eJqcYgMJzrS6fE6elUTidbidIEMmPB8h0pupUYB32v5LXOce1QzKk= X-Received: by 2002:adf:e545:: with SMTP id z5mr5462800wrm.89.1591295493871; Thu, 04 Jun 2020 11:31:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rajesh Kumar Date: Fri, 5 Jun 2020 00:01:22 +0530 Message-ID: Subject: Re: Can we hook a device as device to two different parent devices? To: Warner Losh Cc: Andriy Gapon , freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49dDrR2Vkpz4Vcw X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=AvNI+YLK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rajfbsd@gmail.com designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=rajfbsd@gmail.com X-Spamd-Result: default: False [-1.88 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-0.99)[-0.995]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; NEURAL_SPAM_SHORT(0.07)[0.068]; NEURAL_HAM_LONG(-0.95)[-0.951]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::42f:from]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 18:31:36 -0000 Thanks Warner and Andriy for your answers. Having said they are two separate instances, if the child driver calls the interface of two parents as below device1_interface(child_dev), then device_get_parent(child_dev) in the device1 interface will return device1 reference device2_interface(child_dev), then device_get_parent(child_dev) in the device2 interface will return device2 reference Is that right? Thanks, Rajesh. On Wed, Jun 3, 2020 at 8:59 PM Warner Losh wrote: > > > On Wed, Jun 3, 2020, 8:29 AM Andriy Gapon wrote: > >> On 03/06/2020 14:20, Rajesh Kumar wrote: >> > Hi, >> > >> > Is it really possible to declare a module with two parents? Like the >> > following declarations in the same driver. >> > >> > devclass_t test_dev_devclass; >> > static DEFINE_CLASS_0(test_dev, test_dev_driver, test_dev_methods, >> > sizeof(struct test_dev_ctx)); >> > DRIVER_MODULE(test_dev, *device1*, test_dev_driver, test_dev_devclass, >> > NULL, NULL); >> > DRIVER_MODULE(test_dev, *device2*, test_dev_driver, test_dev_devclass, >> > NULL, NULL); >> > >> > I see similar references in other drivers attaching to both simpleus and >> > ofwbus. So, If it's possible, how to get the reference for both the >> > parents? device_get_parent(test_dev) will give reference of one parent >> > only right, so how to get the reference of the desired parent? >> >> A device can have only one parent. >> The declaration you quoted describes a _driver_ that can attach to devices >> hanging off two different buses. They would still be different devices. >> > > Yes. You can have a driver attach to multiple bus types, but each instance > has a unique parent one exactly on of them. > > If you need to talk to other devices, you'll need to find them by name or > other means. > > Warner > > > >> -- >> Andriy Gapon >> _______________________________________________ >> freebsd-drivers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-drivers >> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org >> " >> >