Re: [PATCH 32/41] staging: lustre: llite: restart short read/write for normal IO

2016-10-14 Thread Greg Kroah-Hartman
On Thu, Oct 13, 2016 at 11:45:28PM +0100, James Simmons wrote:
> 
> > On Wed, Oct 12, 2016 at 12:22:35AM +0100, James Simmons wrote:
> > > 
> > > > On Sun, Oct 02, 2016 at 10:28:28PM -0400, James Simmons wrote:
> > > > > From: Bobi Jam 
> > > > > 
> > > > > If normal IO got short read/write, we'd restart the IO from where
> > > > > we've accomplished until we meet EOF or error happens.
> > > > > 
> > > > > Signed-off-by: Bobi Jam 
> > > > > Signed-off-by: Jinshan Xiong 
> > > > > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6389
> > > > > Reviewed-on: http://review.whamcloud.com/14123
> > > > > Reviewed-by: Andreas Dilger 
> > > > > Reviewed-by: Oleg Drokin 
> > > > > Signed-off-by: James Simmons 
> > > > > ---
> > > > >  drivers/staging/lustre/lnet/libcfs/fail.c  |1 +
> > > > >  .../staging/lustre/lustre/include/obd_support.h|2 +
> > > > >  drivers/staging/lustre/lustre/llite/file.c |   41 
> > > > > 
> > > > >  drivers/staging/lustre/lustre/llite/vvp_io.c   |   19 -
> > > > >  4 files changed, 45 insertions(+), 18 deletions(-)
> > > > 
> > > > Due to other changes in the filesystem tree, this patch no longer
> > > > applies :(
> > > > 
> > > > Can you rebase it and resend?
> > > 
> > > How long will you be accepting patches to merge for? If its going
> > > to be a few weeks like to just include the missing two patches with
> > > the next batch.
> > 
> > I don't understand the question.  I always accept patches, no need to
> > not send them, I'll queue them up to the proper branches as needed.  So
> > what do you mean here?
> 
> I had the impression that more complex patches like the ones I have been
> sending tend to accepted only at the start of the release cycle and only
> simpler patches go into *-rc[3-7] versions. That is why I asked the
> above question.

Yes, that is true, but I will take your "complex" patches and put them
into the -next branch to go to the next kernel release, and only take
bug and regression fixes and add them to the -linus branch to go to the
-rc3-7 releases.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging:vt6656:baseband.h: fix function definition argument without identifier name issue

2016-10-14 Thread Mikhail Golubev
Function definitions arguments should also have an identifier name as
reported by checkpatch.pl.

Signed-off-by: Mikhail Golubev 
---
Changes in v2:
  - Make the changelog comment wrapped at 72 columns.

 drivers/staging/vt6656/baseband.h | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.h 
b/drivers/staging/vt6656/baseband.h
index 7cc1387..fe1c25c 100644
--- a/drivers/staging/vt6656/baseband.h
+++ b/drivers/staging/vt6656/baseband.h
@@ -86,15 +86,15 @@ struct vnt_phy_field {
 unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
unsigned int frame_length, u16 tx_rate);
 
-void vnt_get_phy_field(struct vnt_private *, u32 frame_length,
-  u16 tx_rate, u8 pkt_type, struct vnt_phy_field *);
-
-void vnt_set_short_slot_time(struct vnt_private *);
-void vnt_set_vga_gain_offset(struct vnt_private *, u8);
-void vnt_set_antenna_mode(struct vnt_private *, u8);
-int vnt_vt3184_init(struct vnt_private *);
-void vnt_set_deep_sleep(struct vnt_private *);
-void vnt_exit_deep_sleep(struct vnt_private *);
-void vnt_update_pre_ed_threshold(struct vnt_private *, int scanning);
+void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
+  u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy);
+
+void vnt_set_short_slot_time(struct vnt_private *priv);
+void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data);
+void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode);
+int vnt_vt3184_init(struct vnt_private *priv);
+void vnt_set_deep_sleep(struct vnt_private *priv);
+void vnt_exit_deep_sleep(struct vnt_private *priv);
+void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning);
 
 #endif /* __BASEBAND_H__ */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [lustre-devel] [patch] Staging: lustre: indent an if statement

2016-10-14 Thread Martin Hecht
On 10/14/2016 12:38 AM, James Simmons wrote:
>> This if statement wasn't intended.
just to be sure: in conjunction with the subject of the mail this should
read "indented" instead of "intended", right?
- otherwise this would result in a slightly different patch...


> Acked-by: James Simmons 
>  
>> Signed-off-by: Dan Carpenter 
>>
>> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
>> b/drivers/staging/lustre/lustre/obdclass/cl_object.c
>> index 3199dd4..a102c36 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
>> @@ -335,7 +335,7 @@ int cl_object_getstripe(const struct lu_env *env, struct 
>> cl_object *obj,
>>  if (obj->co_ops->coo_getstripe) {
>>  result = obj->co_ops->coo_getstripe(env, obj, uarg);
>>  if (result)
>> -break;
>> +break;
>>  }
>>  }
>>  return result;
>>
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org




smime.p7s
Description: S/MIME Cryptographic Signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [lustre-devel] [patch] Staging: lustre: indent an if statement

2016-10-14 Thread Dan Carpenter
On Fri, Oct 14, 2016 at 12:36:25PM +0200, Martin Hecht wrote:
> On 10/14/2016 12:38 AM, James Simmons wrote:
> >> This if statement wasn't intended.
> just to be sure: in conjunction with the subject of the mail this should
> read "indented" instead of "intended", right?

Yes, yes.  I should just avoid both words from now on because my fingers
constantly get mixed up.

Greg already applied this so it's too late to send a v2.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] vmbus: add support for dynamic device id's

2016-10-14 Thread Stephen Hemminger
From: Stephen Hemminger 

This patch adds sysfs interface to dynamically bind new UUID values
to existing VMBus device. This is useful for a generic UIO driver to
act similar to uio_pci_generic.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/vmbus_drv.c | 169 +++--
 include/linux/hyperv.h |   6 ++
 2 files changed, 168 insertions(+), 7 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index a259e18..74ce2e5 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -45,6 +45,11 @@
 #include 
 #include "hyperv_vmbus.h"
 
+struct vmbus_dynid {
+   struct list_head node;
+   struct hv_vmbus_device_id id;
+};
+
 static struct acpi_device  *hv_acpi_dev;
 
 static struct completion probe_event;
@@ -500,7 +505,7 @@ static ssize_t device_show(struct device *dev,
 static DEVICE_ATTR_RO(device);
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/ */
-static struct attribute *vmbus_attrs[] = {
+static struct attribute *vmbus_dev_attrs[] = {
&dev_attr_id.attr,
&dev_attr_state.attr,
&dev_attr_monitor_id.attr,
@@ -528,7 +533,7 @@ static struct attribute *vmbus_attrs[] = {
&dev_attr_device.attr,
NULL,
 };
-ATTRIBUTE_GROUPS(vmbus);
+ATTRIBUTE_GROUPS(vmbus_dev);
 
 /*
  * vmbus_uevent - add uevent for our device
@@ -576,7 +581,139 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(
return NULL;
 }
 
+/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
+static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid)
+{
+   struct vmbus_dynid *dynid;
+
+   dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
+   if (!dynid)
+   return -ENOMEM;
+
+   dynid->id.guid = *guid;
+
+   spin_lock(&drv->dynids.lock);
+   list_add_tail(&dynid->node, &drv->dynids.list);
+   spin_unlock(&drv->dynids.lock);
+
+   pr_info("%s: added id %pUl\n", drv->name, &dynid->id.guid.b);
+
+   return driver_attach(&drv->driver);
+}
+
+static void vmbus_free_dynids(struct hv_driver *drv)
+{
+   struct vmbus_dynid *dynid, *n;
+
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+   list_del(&dynid->node);
+   kfree(dynid);
+   }
+   spin_unlock(&drv->dynids.lock);
+}
 
+/* Parse string of form: 1b4e28ba-2fa1-11d2-883f-b9a761bde3f */
+static int get_uuid_le(const char *str, uuid_le *uu)
+{
+   unsigned int b[16];
+   int i;
+
+   if (strlen(str) < 37)
+   return -1;
+
+   for (i = 0; i < 36; i++) {
+   switch (i) {
+   case 8: case 13: case 18: case 23:
+   if (str[i] != '-')
+   return -1;
+   break;
+   default:
+   if (!isxdigit(str[i]))
+   return -1;
+   }
+   }
+
+   /* unparse little endian output byte order */
+   if (sscanf(str,
+  "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+  &b[3], &b[2], &b[1], &b[0],
+  &b[5], &b[4], &b[7], &b[6], &b[8], &b[9],
+  &b[10], &b[11], &b[12], &b[13], &b[14], &b[15]) != 16)
+   return -1;
+
+   for (i = 0; i < 16; i++)
+   uu->b[i] = b[i];
+   return 0;
+}
+
+/*
+ * store_new_id - sysfs frontend to vmbus_add_dynid()
+ *
+ * Allow GUIDs to be added to an existing driver via sysfs.
+ */
+static ssize_t store_new_id(struct device_driver *driver, const char *buf,
+   size_t count)
+{
+   struct hv_driver *drv = drv_to_hv_drv(driver);
+   const struct hv_vmbus_device_id *ids = drv->id_table;
+   uuid_le guid = NULL_UUID_LE;
+   ssize_t retval;
+
+   if (get_uuid_le(buf, &guid) != 0)
+   return -EINVAL;
+
+   if (hv_vmbus_get_id(ids, &guid))
+   return -EEXIST;
+
+   retval = vmbus_add_dynid(drv, &guid);
+   if (retval)
+   return retval;
+   return count;
+}
+static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
+
+/*
+ * store_remove_id - remove a PCI device ID from this driver
+ *
+ * Removes a dynamic pci device ID to this driver.
+ */
+static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
+  size_t count)
+{
+   struct hv_driver *drv = drv_to_hv_drv(driver);
+   struct vmbus_dynid *dynid, *n;
+   uuid_le guid = NULL_UUID_LE;
+   size_t retval = -ENODEV;
+
+   if (get_uuid_le(buf, &guid))
+   return -EINVAL;
+
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+   struct hv_vmbus_device_id *id = &dynid->id;
+
+   if (!uuid_le_cmp(id->guid, guid)) {
+   list_del(&dynid->node);
+   kfree(dynid);
+

[PATCH 2/2] staging: hv_uio userspace i/o driver for Hyper-V VMbus

2016-10-14 Thread Stephen Hemminger
From: Stephen Hemminger 

This is a staging driver to enable userspace networking on VMBus.
Hyper-V does not support guest IOMMU, so this is an alternative
to allow for applications using DPDK.

This is based on earlier GPL driver developed for DPDK by Brocade.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/connection.c |   1 +
 drivers/staging/Kconfig |   2 +
 drivers/staging/Makefile|   1 +
 drivers/staging/hv_uio/Kconfig  |   6 ++
 drivers/staging/hv_uio/Makefile |   4 +
 drivers/staging/hv_uio/hv_uio.c | 222 
 6 files changed, 236 insertions(+)
 create mode 100644 drivers/staging/hv_uio/Kconfig
 create mode 100644 drivers/staging/hv_uio/Makefile
 create mode 100644 drivers/staging/hv_uio/hv_uio.c

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 78e6368..6ce8b87 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -39,6 +39,7 @@ struct vmbus_connection vmbus_connection = {
.conn_state = DISCONNECTED,
.next_gpadl_handle  = ATOMIC_INIT(0xE1E10),
 };
+EXPORT_SYMBOL_GPL(vmbus_connection);
 
 /*
  * Negotiated protocol version with the host.
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 58a7b35..fd31191 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -106,4 +106,6 @@ source "drivers/staging/greybus/Kconfig"
 
 source "drivers/staging/vc04_services/Kconfig"
 
+source "drivers/staging/hv_uio/Kconfig"
+
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 2fa9745..ce6bd66 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -42,3 +42,4 @@ obj-$(CONFIG_ISDN_I4L)+= i4l/
 obj-$(CONFIG_KS7010)   += ks7010/
 obj-$(CONFIG_GREYBUS)  += greybus/
 obj-$(CONFIG_BCM2708_VCHIQ)+= vc04_services/
+obj-$(CONFIG_HV_UIO)   += hv_uio/
diff --git a/drivers/staging/hv_uio/Kconfig b/drivers/staging/hv_uio/Kconfig
new file mode 100644
index 000..a2b1eb2
--- /dev/null
+++ b/drivers/staging/hv_uio/Kconfig
@@ -0,0 +1,6 @@
+config HV_UIO
+   tristate "Microsoft Hyper-V UIO driver"
+   depends on HYPERV_NET && UIO
+   help
+ Userspace interface for Hyper-V VMBus.
+ Can be used with DPDK to provide access to network device.
diff --git a/drivers/staging/hv_uio/Makefile b/drivers/staging/hv_uio/Makefile
new file mode 100644
index 000..65483b3
--- /dev/null
+++ b/drivers/staging/hv_uio/Makefile
@@ -0,0 +1,4 @@
+#
+# Makefile for Hyper UIO driver
+#
+obj-$(CONFIG_HV_UIO) += hv_uio.o
diff --git a/drivers/staging/hv_uio/hv_uio.c b/drivers/staging/hv_uio/hv_uio.c
new file mode 100644
index 000..4996454
--- /dev/null
+++ b/drivers/staging/hv_uio/hv_uio.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * Copyright (c) 2016, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see .
+ *
+ */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../hv/hyperv_vmbus.h"
+
+/*
+ * List of resources to be mapped to user space
+ * can be extended up to MAX_UIO_MAPS(5) items
+ */
+enum hv_uio_map {
+   TXRX_RING_MAP = 0,
+   INT_PAGE_MAP,
+   MON_PAGE_MAP,
+};
+
+#define HV_RING_SIZE   512
+
+struct hv_uio_private_data {
+   struct uio_info info;
+   struct hv_device *device;
+};
+
+static int
+hv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)
+{
+   int mi;
+
+   if (vma->vm_pgoff >= MAX_UIO_MAPS)
+   return -EINVAL;
+
+   if (info->mem[vma->vm_pgoff].size == 0)
+   return -EINVAL;
+
+   mi = (int)vma->vm_pgoff;
+
+   return remap_pfn_range(vma, vma->vm_start,
+  virt_to_phys((void *)info->mem[mi].addr) >> 
PAGE_SHIFT,
+  vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
+/*
+ * This is the irqcontrol callback to be registered to uio_info.
+ * It can be used to disable/enable interrupt from user space processes.
+ *
+ * @param info
+ *  pointer to uio_info.
+ * @param irq_state
+ *  state value. 1 to enable interrupt, 0 to disable interrupt.
+ */
+static int
+hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
+{
+   struct hv_uio_private_data *pdata = info->priv;
+   struct hv

Re: [PATCH 2/2] staging: hv_uio userspace i/o driver for Hyper-V VMbus

2016-10-14 Thread Greg KH
On Fri, Oct 14, 2016 at 09:43:52AM -0700, Stephen Hemminger wrote:
> From: Stephen Hemminger 
> 
> This is a staging driver to enable userspace networking on VMBus.
> Hyper-V does not support guest IOMMU, so this is an alternative
> to allow for applications using DPDK.
> 
> This is based on earlier GPL driver developed for DPDK by Brocade.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/hv/connection.c |   1 +
>  drivers/staging/Kconfig |   2 +
>  drivers/staging/Makefile|   1 +
>  drivers/staging/hv_uio/Kconfig  |   6 ++
>  drivers/staging/hv_uio/Makefile |   4 +
>  drivers/staging/hv_uio/hv_uio.c | 222 
> 

Why staging?  If you do this, I need a TODO file to list what needs to
be done to it in order to get it out of staging...

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: hv_uio userspace i/o driver for Hyper-V VMbus

2016-10-14 Thread Greg KH
On Fri, Oct 14, 2016 at 07:06:47PM +0200, Greg KH wrote:
> On Fri, Oct 14, 2016 at 09:43:52AM -0700, Stephen Hemminger wrote:
> > From: Stephen Hemminger 
> > 
> > This is a staging driver to enable userspace networking on VMBus.
> > Hyper-V does not support guest IOMMU, so this is an alternative
> > to allow for applications using DPDK.
> > 
> > This is based on earlier GPL driver developed for DPDK by Brocade.
> > 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  drivers/hv/connection.c |   1 +
> >  drivers/staging/Kconfig |   2 +
> >  drivers/staging/Makefile|   1 +
> >  drivers/staging/hv_uio/Kconfig  |   6 ++
> >  drivers/staging/hv_uio/Makefile |   4 +
> >  drivers/staging/hv_uio/hv_uio.c | 222 
> > 
> 
> Why staging?  If you do this, I need a TODO file to list what needs to
> be done to it in order to get it out of staging...

To follow up on this, I don't see anything obvious about why it needs to
be a staging driver.  Looks tiny and simple to me for a UIO driver.  All
of the "real work" needs to happen in DPDK, somehow, have fun with that!

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] staging: hv_uio userspace i/o driver for Hyper-V VMbus

2016-10-14 Thread Stephen Hemminger
On Fri, 14 Oct 2016 19:06:47 +0200
Greg KH  wrote:

> On Fri, Oct 14, 2016 at 09:43:52AM -0700, Stephen Hemminger wrote:
> > From: Stephen Hemminger 
> > 
> > This is a staging driver to enable userspace networking on VMBus.
> > Hyper-V does not support guest IOMMU, so this is an alternative
> > to allow for applications using DPDK.
> > 
> > This is based on earlier GPL driver developed for DPDK by Brocade.
> > 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  drivers/hv/connection.c |   1 +
> >  drivers/staging/Kconfig |   2 +
> >  drivers/staging/Makefile|   1 +
> >  drivers/staging/hv_uio/Kconfig  |   6 ++
> >  drivers/staging/hv_uio/Makefile |   4 +
> >  drivers/staging/hv_uio/hv_uio.c | 222 
> >   
> 
> Why staging?  If you do this, I need a TODO file to list what needs to
> be done to it in order to get it out of staging...

I think this needs to go into staging because not convinced that it is 
completely
secure.  For example, a malicious userspace driver could certainly break other
VMBus drivers on the system (shared notification areas). Also, the ABI is not
stable; new features are certain to break compatibility.

Longer term, a better solution is to support something like VFIO which provides
a better API. But would have to be like VFIO-noiommu and VFIO is specific to
PCI right now.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: replace DGNC_VERIFY_BOARD macro

2016-10-14 Thread Fernando Apesteguia
The patch replaces the macro with a function (dgnc_get_board) and
substitutes the macro statement with a call to that function and a
comparison on the returned value.

This removes a checkpatch warning.

Signed-off-by: Fernando Apesteguia 
---
 drivers/staging/dgnc/dgnc_sysfs.c | 74 +++
 1 file changed, 51 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_sysfs.c 
b/drivers/staging/dgnc/dgnc_sysfs.c
index 290bf6e..3ea23a9 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -90,17 +90,21 @@ void dgnc_remove_driver_sysfiles(struct pci_driver 
*dgnc_driver)
driver_remove_file(driverfs, &driver_attr_pollrate);
 }
 
-#define DGNC_VERIFY_BOARD(p, bd)   \
-   do {\
-   if (!p) \
-   return 0;   \
-   \
-   bd = dev_get_drvdata(p);\
-   if (!bd || bd->magic != DGNC_BOARD_MAGIC)   \
-   return 0;   \
-   if (bd->state != BOARD_READY)   \
-   return 0;   \
-   } while (0)
+static struct dgnc_board *dgnc_get_board(struct device *p)
+{
+   struct dgnc_board *bd;
+
+   if (!p)
+   return NULL;
+
+   bd = dev_get_drvdata(p);
+   if (!bd || bd->magic != DGNC_BOARD_MAGIC)
+   return NULL;
+   if (bd->state != BOARD_READY)
+   return NULL;
+
+   return bd;
+}
 
 static ssize_t vpd_show(struct device *p, struct device_attribute *attr,
char *buf)
@@ -109,7 +113,9 @@ static ssize_t vpd_show(struct device *p, struct 
device_attribute *attr,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
count += sprintf(buf + count,
"\n  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F");
@@ -130,7 +136,9 @@ static ssize_t serial_number_show(struct device *p,
struct dgnc_board *bd;
int count = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
if (bd->serial_num[0] == '\0')
count += sprintf(buf + count, "\n");
@@ -148,7 +156,9 @@ static ssize_t ports_state_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
@@ -166,7 +176,9 @@ static ssize_t ports_baud_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count +=  snprintf(buf + count, PAGE_SIZE - count,
@@ -184,7 +196,9 @@ static ssize_t ports_msignals_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
struct channel_t *ch = bd->channels[i];
@@ -215,7 +229,9 @@ static ssize_t ports_iflag_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
@@ -233,7 +249,9 @@ static ssize_t ports_cflag_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
@@ -251,7 +269,9 @@ static ssize_t ports_oflag_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
@@ -269,7 +289,9 @@ static ssize_t ports_lflag_show(struct device *p,
int count = 0;
int i = 0;
 
-   DGNC_VERIFY_BOARD(p, bd);
+   bd = dgnc_get_board(p);
+   if (!bd)
+   return 0;
 
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
@@ -287,7 +309,9 @@ static ssize_t ports_digi_flag_show(struct device *p

[PATCH 10/25] [media] radio-bcm2048: don't ignore errors

2016-10-14 Thread Mauro Carvalho Chehab
Remove this warning:

drivers/staging/media/bcm2048/radio-bcm2048.c: In function 
'bcm2048_set_rds_no_lock':
drivers/staging/media/bcm2048/radio-bcm2048.c:467:6: warning: variable 'err' 
set but not used [-Wunused-but-set-variable]
  int err;
  ^~~

By returning the error code.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index ea15cc638097..4d9bd02ede47 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -482,6 +482,8 @@ static int bcm2048_set_rds_no_lock(struct bcm2048_device 
*bdev, u8 rds_on)
   flags);
memset(&bdev->rds_info, 0, sizeof(bdev->rds_info));
}
+   if (err)
+   return err;
 
return bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM,
bdev->cache_fm_rds_system);
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[patch] greybus: fix a leak on error in gb_module_create()

2016-10-14 Thread Dan Carpenter
We should release ->interfaces[0] as well.

Fixes: b15d97d77017 ("greybus: core: add module abstraction")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index 69f67dd..660b467 100644
--- a/drivers/staging/greybus/module.c
+++ b/drivers/staging/greybus/module.c
@@ -127,7 +127,7 @@ struct gb_module *gb_module_create(struct gb_host_device 
*hd, u8 module_id,
return module;
 
 err_put_interfaces:
-   for (--i; i > 0; --i)
+   for (--i; i >= 0; --i)
gb_interface_put(module->interfaces[i]);
 
put_device(&module->dev);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel