Re: [PATCH 02/15] hyperv: Add a function to detect hv_device

From: Greg KH
Date: Thu Dec 01 2016 - 15:38:38 EST


On Thu, Dec 01, 2016 at 09:35:47PM +0100, Greg KH wrote:
> On Thu, Dec 01, 2016 at 09:28:39AM -0800, kys@xxxxxxxxxxxxxxxxxxxxxx wrote:
> > From: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> > Signed-off-by: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>
> > ---
> > 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...)

And, to make this even worse, you never use this function in this
series, making this something that no one even needs!!!

ugh.

I'm dropping this whole series, sorry, get it together, this was a
mess...

greg k-h