Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbbEJVCX (ORCPT ); Sun, 10 May 2015 17:02:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50140 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbbEJVAK (ORCPT ); Sun, 10 May 2015 17:00:10 -0400 Date: Sun, 10 May 2015 15:16:09 +0200 From: Greg KH To: "J. German Rivera" Cc: arnd@arndb.de, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, stuart.yoder@freescale.com, bhupesh.sharma@freescale.com, agraf@suse.de, bhamciu1@freescale.com, Bharat Bhushan , nir.erez@freescale.com, itai.katz@freescale.com, scottwood@freescale.com, R89243@freescale.com, richard.schmitt@freescale.com Subject: Re: [PATCH v2 2/7] staging: fsl_-mc: add device binding path 'driver_override' Message-ID: <20150510131609.GB4608@kroah.com> References: <1430947708-10521-1-git-send-email-German.Rivera@freescale.com> <1430947708-10521-3-git-send-email-German.Rivera@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430947708-10521-3-git-send-email-German.Rivera@freescale.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3815 Lines: 118 On Wed, May 06, 2015 at 04:28:23PM -0500, J. German Rivera wrote: > From: Bharat Bhushan > > This patch is required for vfio-fsl-mc meta driver to successfully bind > layerscape container devices for device passthrough. This patch adds > a mechanism to allow a layerscape device to specify a driver rather than > a layerscape driver provide a device match. > > This patch is based on following proposed patches for PCI and platform devices > - https://lkml.org/lkml/2014/4/8/571 :- For Platform devices > - http://lists-archives.com/linux-kernel/28030441-pci-introduce-new-device-binding-path-using-pci_dev-driver_override.html :- For PCI devices > > Example to allow a device (dprc.1) to specifically bind > with driver (vfio-fsl-mc):- > - echo vfio-fsl-mc > /sys/bus/fsl-mc/devices/dprc.1/driver_override > - echo dprc.1 > /sys/bus/fsl-mc/drivers/fsl_mc_dprc/unbind > - echo dprc.1 > /sys/bus/fsl-mc/drivers/vfio-fsl-mc/bind > > Signed-off-by: J. German Rivera > Reviewed-by: Stuart Yoder > Tested-by: Stuart Yoder > --- > Changes in v2: > none > > drivers/staging/fsl-mc/bus/mc-bus.c | 67 +++++++++++++++++++++++++++++++++++++ > drivers/staging/fsl-mc/include/mc.h | 2 ++ > 2 files changed, 69 insertions(+) > > diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c > index d51120a..0e9cba8 100644 > --- a/drivers/staging/fsl-mc/bus/mc-bus.c > +++ b/drivers/staging/fsl-mc/bus/mc-bus.c > @@ -58,6 +58,12 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv) > if (WARN_ON(!fsl_mc_bus_type.dev_root)) > goto out; > > + /* When driver_override is set, only bind to the matching driver */ > + if (mc_dev->driver_override) { > + found = !strcmp(mc_dev->driver_override, mc_drv->driver.name); > + goto out; > + } > + > if (!mc_drv->match_id_table) > goto out; > > @@ -116,10 +122,69 @@ static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) > return 0; > } > > +static ssize_t driver_override_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); > + const char *driver_override, *old = mc_dev->driver_override; > + char *cp; > + > + if (WARN_ON(dev->bus != &fsl_mc_bus_type)) > + return -EINVAL; > + > + if (count > PATH_MAX) > + return -EINVAL; > + > + driver_override = kstrndup(buf, count, GFP_KERNEL); > + if (!driver_override) > + return -ENOMEM; > + > + cp = strchr(driver_override, '\n'); > + if (cp) > + *cp = '\0'; > + > + if (strlen(driver_override)) { > + mc_dev->driver_override = driver_override; > + } else { > + kfree(driver_override); > + mc_dev->driver_override = NULL; > + } > + > + kfree(old); > + > + return count; > +} > + > +static ssize_t driver_override_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); > + > + return sprintf(buf, "%s\n", mc_dev->driver_override); > +} > + > +static DEVICE_ATTR_RW(driver_override); Documenation for this new sysfs attribute? > + > +static struct attribute *fsl_mc_dev_attrs[] = { > + &dev_attr_driver_override.attr, > + NULL, > +}; > + > +static const struct attribute_group fsl_mc_dev_group = { > + .attrs = fsl_mc_dev_attrs, > +}; > + > +static const struct attribute_group *fsl_mc_dev_groups[] = { > + &fsl_mc_dev_group, > + NULL, > +}; ATTRIBUTE_GROUP()? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/