From owner-freebsd-drivers@freebsd.org Wed Jun 3 15:29:20 2020 Return-Path: Delivered-To: freebsd-drivers@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 DDB7D339AB8 for ; Wed, 3 Jun 2020 15:29:20 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) (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 49cXrb6rYzz4dBW for ; Wed, 3 Jun 2020 15:29:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x734.google.com with SMTP id w3so2525098qkb.6 for ; Wed, 03 Jun 2020 08:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GrgyiUIrwkq+y80N3Xo5bFrdfICx0GeEPNszr6b9zqQ=; b=qCEjcQ0XtjmUbz/w1Bf1RC+CEEtijl+eQZkfjUzDWshUEhCHq2HoI32tL+xo2t0DCv ZiHc/QQbLEWtlTCaVVwVoTjPCSNab2Y5aX89ZHKeZHbehGcA5wSatviOnI/+x0BCbkqC DkUAsoIUh9ubjstWB9ajBVB9+wp7D1uO+arBo+Qs/xsZTdnn15VEgtbRZEpOqDQDUBtX /b3IF0vbDgNB0VaWdyqCuwX4uSl5TZWLQdkhaC/x3Vcz7lHPdMyJYkyE9MsLRnV+MRf+ odZ1P3NjH8j8ogtmd4Zsyjinp3VERkSIpJD8LNZWvgzLtvYhc2XmrVEWC9JrIoPVA3TR 8IGA== 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=GrgyiUIrwkq+y80N3Xo5bFrdfICx0GeEPNszr6b9zqQ=; b=OmOZ24+Uc0swBhRDadNeNHS6SYKTfA/M3yQKGl1KN3aXzRTyV9+MCqNmhozrGRR/1y OkMYpWo12lx8AcZl0Yca8zRpVyKbfvLuTlh2fAKL+99rrjAGEvULeVgQZQ6HdYhK5adX yHYpY8Q3zeoz7w1AnVS2+nWD06p55CK+0EEO88uUp4DnCNAagzd4un13gT4DZYKEK1hb PfAfZw0KspO1RbpbcTaaEVD+od/KaTuOFDPhzi1KqDzSRY5jQwY7H+tGtISAFSSeLAnw theiQFqhQH28ZJXzu43Z9jqSwL9gaSwlvG7MJy0fBmC4HnTW82xc2+SMIsQNhD9gzXSE qsDg== X-Gm-Message-State: AOAM532Pjzz4CgZI2sUTDFaD/5udgO9yNbR1e3z5qr1jz/dTQN4vipRI pG8KQDRC2eCjbVxH5+tea5lAl2bp/LUiFXBAgVpWHDiC X-Google-Smtp-Source: ABdhPJwoKtcQTwJYw+WFkYl2INiy6ZlW912D6iNvYMcfUzw4Yj40FNuax6CAhdusb/c/oRN2FQ2lEhfVODNp0Wsfb88= X-Received: by 2002:a37:9f09:: with SMTP id i9mr216086qke.60.1591198158502; Wed, 03 Jun 2020 08:29:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Wed, 3 Jun 2020 09:29:06 -0600 Message-ID: Subject: Re: Can we hook a device as device to two different parent devices? To: Andriy Gapon Cc: Rajesh Kumar , freebsd-drivers@freebsd.org, FreeBSD Hackers X-Rspamd-Queue-Id: 49cXrb6rYzz4dBW X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=qCEjcQ0X; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::734) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.97 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.98)[-0.976]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.03)[-1.028]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-drivers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.97)[-0.971]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::734:from]; R_SPF_NA(0.00)[no SPF record]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 15:29:20 -0000 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" >