Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757251AbcLAUpA (ORCPT ); Thu, 1 Dec 2016 15:45:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46856 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753431AbcLAUo7 (ORCPT ); Thu, 1 Dec 2016 15:44:59 -0500 Date: Thu, 1 Dec 2016 21:35:47 +0100 From: Greg KH To: kys@microsoft.com Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, Haiyang Zhang Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device Message-ID: <20161201203547.GB1602@kroah.com> References: <1480613287-7748-1-git-send-email-kys@exchange.microsoft.com> <1480613332-7788-1-git-send-email-kys@exchange.microsoft.com> <1480613332-7788-2-git-send-email-kys@exchange.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480613332-7788-2-git-send-email-kys@exchange.microsoft.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1255 Lines: 36 On Thu, Dec 01, 2016 at 09:28:39AM -0800, kys@exchange.microsoft.com wrote: > From: Haiyang Zhang > > Signed-off-by: Haiyang Zhang > Signed-off-by: K. Y. Srinivasan > --- > drivers/hv/vmbus_drv.c | 6 ++++++ > include/linux/hyperv.h | 2 ++ > 2 files changed, 8 insertions(+), 0 deletions(-) > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > index 0276d2e..1730ac0 100644 > --- a/drivers/hv/vmbus_drv.c > +++ b/drivers/hv/vmbus_drv.c > @@ -692,6 +692,12 @@ struct onmessage_work_context { > struct hv_message msg; > }; > > +bool device_is_hyperv(struct device *dev) > +{ > + return dev->release == vmbus_device_release; > +} > +EXPORT_SYMBOL_GPL(device_is_hyperv); Wait, eek, no! That's NOT how you determine a device type, if you really even ever need to do that. Why are you needing this? You should always "just know" what type of device a struct device * is, that's what we rely on in the driver model. Otherwise things get messy very very quickly. Sorry, I can't take this without a ton of justification, and even then, you need to do this correctly (and no, I'm not going to tell you how to do that as I don't like it being done...) greg k-h