staging: fsl-mc: Cleanup and bug fixes
v2 cover staging: fsl-mc: Cleanup and bug fixes
This patch series includes the following code cleanup and bug fixes for the fsl-mc bus driver:
Patch 1: Naming cleanup in fsl_mc-portal_allocate Patch 2: fsl_mc_io object refactoring
Patch 3: dpmcp opening/closing refactoring
Patch 4: Changed dev_info() calls to dev_dbg()
Patch 5: Changed types of flags, portal size in
Patch 6: Removed unused DPMCP macros
Patch 7: Fixed alignment of copyright comment
Patch 8: Fixed bug in fsl_mc_allocator_remove
Patch 9: Refactored error exit in allocator probe/remove Patch 10: Fixed WARN_ON() in fsl_mc_resource_pool_remove_device Patch 11: Fixed bug in uninitialized root dprc irq count Patch 12: Added missing initializer in fsl_mc_bus_driver
CHANGE HISTORY
Changes in v2
- Updated only patch 3. There was some leftover code that needed to be removed as part of the refactoring done in that patch.
PATCH v2 1/12 staging: fsl-mc: Naming cleanup in fsl_mc-portal_allocate
mc_adev is a local variable for the allocated dpmcp object. Renamed mc_adev as dpmcp_dev for clarity.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +7 -7
@@ -284,7 +284,7 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,struct fsl_mc_bus *mc_bus;phys_addr_t mc_portal_phys_addr;size_t mc_portal_size; -struct fsl_mc_device *mc_adev; +struct fsl_mc_device *dpmcp_dev;int error = -EINVAL ;struct fsl_mc_resource *resource =NULL ;struct fsl_mc_io *mc_io =NULL ;
@@ -304,16 +304,16 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,if (error <0 )return error; - mc_adev = resource->data; -if (WARN_ON (!mc_adev)) + dpmcp_dev = resource->data; +if (WARN_ON (!dpmcp_dev)) goto error_cleanup_resource; -if (WARN_ON (mc_adev->obj_desc.region_count ==0 )) +if (WARN_ON (dpmcp_dev->obj_desc.region_count ==0 )) goto error_cleanup_resource; - mc_portal_phys_addr = mc_adev->regions[0 ].start; - mc_portal_size = mc_adev->regions[0 ].end - - mc_adev->regions[0 ].start +1 ; + mc_portal_phys_addr = dpmcp_dev->regions[0 ].start; + mc_portal_size = dpmcp_dev->regions[0 ].end - + dpmcp_dev->regions[0 ].start +1 ;if (WARN_ON (mc_portal_size != mc_bus_dev->mc_io->portal_size)) goto error_cleanup_resource;
--
2.3.3
Greg KH
maintainerRe: [PATCH v2 01/12] staging: fsl-mc: Naming cleanup in fsl_mc-portal_allocate
Quoted 6 lines · J. German Rivera
mc_adevis a local variable for the allocated dpmcp object. Renamedmc_adevasdpmcp_devfor clarity.
---
CHANGE HISTORYChanges in v2: none
None of the patches in this series has a signed-off-by: line, as required by Documentation/SubmittingPatches, so I'm guessing you don't want them actually applied :(
RE: [PATCH v2 01/12] staging: fsl-mc: Naming cleanup in fsl_mc-portal_allocate
Quoted 18 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Saturday, October 17, 2015 1:16 AM
To: Rivera Jose-B46482
Cc: [email protected]; [email protected]; linux- [email protected]; Hamciuc Bogdan-BHAMCIU1; Sharma Bhupesh-B45370; [email protected]; Yoder Stuart-B08248; Erez Nir-RM30794; katz Itai-RM05202; Wood Scott-B07421; Pan Lijun-B44306; Li Yang-Leo-R58472; Marginean Alexandru-R89243; [email protected]; Schmitt Richard-B43082
Subject: Re: [PATCH v2 01/12] staging: fsl-mc: Naming cleanup in fsl_mc-portal_allocateQuoted 5 lines · J. German Rivera
mc_adevis a local variable for the allocated dpmcp object. Renamedmc_adevasdpmcp_devfor clarity.
---
CHANGE HISTORY
Quoted 5 lines
Quoted 1 line
Changes in v2: none
None of the patches in this series has a signed-off-by: line, as required by
Documentation/SubmittingPatches, so I'm guessing you don't want them actually applied :(
Greg,
I apologize for that oversight. I'll send a respin fixing this.
Thanks,
German
PATCH v2 2/12 staging: fsl-mc: fsl_mc_io object refactoring
In reply to J. German RiveraEach fsl_mc_io object is associated with an fsl_mc_device object of type "dpmcp" representing the MC portal associated with the fsl_mc_io object. Before, we were representing this association with an fsl_mc_resource pointer. To enhance code clarity, it is more straight forward to use an fsl_mc_device pointer instead. So, this change replaces the 'resource' field in the fsl_mc_io object with 'dpmcp_dev'. Also, it changes parameter 'resource' of fsl_create_mc_io() to be an fsl_mc_device pointer instead.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 34 ++++++++++++++++++------------- drivers/staging/fsl-mc/bus/mc-sys.c | 16 +++++++++++---- drivers/staging/fsl-mc/include/mc-sys.h | 8 +++----- 3 files changed, 35 insertions(+), 23 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +20 -14
@@ -320,7 +320,7 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev, error =fsl_create_mc_io (&mc_bus_dev->dev, mc_portal_phys_addr, - mc_portal_size, resource, + mc_portal_size, dpmcp_dev, mc_io_flags, &mc_io);if (error <0 ) goto error_cleanup_resource;
@@ -342,12 +342,22 @@ EXPORT_SYMBOL_GPL(fsl_mc_portal_allocate);*/ void fsl_mc_portal_free (struct fsl_mc_io *mc_io) { +struct fsl_mc_device *dpmcp_dev;struct fsl_mc_resource *resource; - resource = mc_io->resource; -if (WARN_ON (resource->type !=FSL_MC_POOL_DPMCP )) +/* +* Every mc_io obtained by calling fsl_mc_portal_allocate() is supposed +* to have a DPMCP object associated with. +*/ + dpmcp_dev = mc_io->dpmcp_dev; +if (WARN_ON (!dpmcp_dev)) +return ; + + resource = dpmcp_dev->resource; +if (WARN_ON (!resource || resource->type !=FSL_MC_POOL_DPMCP ))return ; -if (WARN_ON (!resource->data)) + +if (WARN_ON (resource->data != dpmcp_dev))return ;fsl_destroy_mc_io (mc_io);
@@ -364,30 +374,26 @@ int fsl_mc_portal_reset(struct fsl_mc_io *mc_io) {int error;u16 token; -struct fsl_mc_resource *resource = mc_io->resource; -struct fsl_mc_device *mc_dev = resource->data; +struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev; -if (WARN_ON (resource->type !=FSL_MC_POOL_DPMCP )) -return -EINVAL ; - -if (WARN_ON (!mc_dev)) +if (WARN_ON (!dpmcp_dev))return -EINVAL ; - error =dpmcp_open (mc_io,0 , mc_dev->obj_desc.id, &token); + error =dpmcp_open (mc_io,0 , dpmcp_dev->obj_desc.id, &token);if (error <0 ) { -dev_err (&mc_dev->dev,"dpmcp_open() failed: %d\n" , error); +dev_err (&dpmcp_dev->dev,"dpmcp_open() failed: %d\n" , error);return error; } error =dpmcp_reset (mc_io,0 , token);if (error <0 ) { -dev_err (&mc_dev->dev,"dpmcp_reset() failed: %d\n" , error); +dev_err (&dpmcp_dev->dev,"dpmcp_reset() failed: %d\n" , error);return error; } error =dpmcp_close (mc_io,0 , token);if (error <0 ) { -dev_err (&mc_dev->dev,"dpmcp_close() failed: %d\n" , error); +dev_err (&dpmcp_dev->dev,"dpmcp_close() failed: %d\n" , error);return error; }
drivers/staging/fsl-mc/bus/mc-sys.c +12 -4
@@ -34,10 +34,12 @@#include "../include/mc-sys.h" #include "../include/mc-cmd.h" +#include "../include/mc.h" #include <linux/delay.h> #include <linux/slab.h> #include <linux/ioport.h> #include <linux/device.h> +#include "dpmcp.h" /** * Timeout in jiffies to wait for the completion of an MC command
@@ -60,8 +62,8 @@* @dev: device to be associated with the MC I/O object * @mc_portal_phys_addr: physical address of the MC portal to use * @mc_portal_size: size in bytes of the MC portal -* @resource: Pointer to MC bus object allocator resource associated -* with this MC I/O object or NULL if none. +* @dpmcp-dev: Pointer to the DPMCP object associated with this MC I/O +* object or NULL if none. * @flags: flags for the new MC I/O object * @new_mc_io: Area to return pointer to newly created MC I/O object *
@@ -70,7 +72,7 @@int __must_check fsl_create_mc_io (struct device *dev,phys_addr_t mc_portal_phys_addr,u32 mc_portal_size, -struct fsl_mc_resource *resource, +struct fsl_mc_device *dpmcp_dev,u32 flags,struct fsl_mc_io **new_mc_io) {struct fsl_mc_io *mc_io;
@@ -85,7 +87,8 @@ int __must_check fsl_create_mc_io(struct device *dev, mc_io->flags = flags; mc_io->portal_phys_addr = mc_portal_phys_addr; mc_io->portal_size = mc_portal_size; - mc_io->resource = resource; + mc_io->dpmcp_dev = dpmcp_dev; + dpmcp_dev->mc_io = mc_io; res = devm_request_mem_region(dev, mc_portal_phys_addr, mc_portal_size,
@@ -126,6 +129,11 @@ void fsl_destroy_mc_io(struct fsl_mc_io *mc_io) mc_io->portal_size); mc_io->portal_virt_addr =NULL ; +if (mc_io->dpmcp_dev) { +WARN_ON (mc_io->dpmcp_dev->mc_io != mc_io); + mc_io->dpmcp_dev->mc_io =NULL ; + } +devm_kfree (mc_io->dev, mc_io); }EXPORT_SYMBOL_GPL (fsl_destroy_mc_io);
drivers/staging/fsl-mc/include/mc-sys.h +3 -5
@@ -50,9 +50,7 @@ struct mc_command;* @portal_size: MC command portal size in bytes * @portal_phys_addr: MC command portal physical address * @portal_virt_addr: MC command portal virtual address -* @resource: generic resource associated with the MC portal if -* the MC portal came from a resource pool, or NULL if the MC portal -* is permanently bound to a device (e.g., a DPRC) +* @dpmcp_dev: pointer to the DPMCP device associated with the MC portal. */ struct fsl_mc_io {struct device *dev;
@@ -60,13 +58,13 @@ struct fsl_mc_io {u32 portal_size;phys_addr_t portal_phys_addr;void __iomem *portal_virt_addr; -struct fsl_mc_resource *resource; +struct fsl_mc_device *dpmcp_dev; };int __must_check fsl_create_mc_io (struct device *dev,phys_addr_t mc_portal_phys_addr,u32 mc_portal_size, -struct fsl_mc_resource *resource, +struct fsl_mc_device *dpmcp_dev,u32 flags,struct fsl_mc_io **new_mc_io);void fsl_destroy_mc_io (struct fsl_mc_io *mc_io);
--
2.3.3
PATCH v2 3/12 staging: fsl-mc: dpmcp opening/closing refactoring
In reply to J. German RiveraBefore, we were opening and closing a mc_io's dpmcp object in fsl_mc_portal_reset(), since that was the only function that was calling dpmcp MC operations. However, it is better for maintainability to open the dpmcp object when it gets associated with an mc_io object, and close it when this association is terminated. This way, we are free to call dpmcp operations on a mc_io's dpmcp object at any time, without having to check if the dpmcp object is opened or not.
Consequently, the creation/teardown of the association between an mc_io object and a dpmcp is now encapsulated in two functions:
fsl_mc_io_set_dpmcp()/fsl_mc_io_unset_dpmcp(). Besides, setting the corresponding pointers for the association, these functions open and close the dpmcp object respectively.
---
CHANGE HISTORY
Changes in v2:
- Removed leftover code that needed to be removed as part of the refactoring done in this patch
drivers/staging/fsl-mc/bus/mc-allocator.c | 15 +------ drivers/staging/fsl-mc/bus/mc-sys.c | 74 ++++++++++++++++++++++++++++--- drivers/staging/fsl-mc/include/mc-sys.h | 5 +++ 3 files changed, 73 insertions(+), 21 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +1 -14
@@ -373,30 +373,17 @@ EXPORT_SYMBOL_GPL(fsl_mc_portal_free);int fsl_mc_portal_reset (struct fsl_mc_io *mc_io) {int error; -u16 token;struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev;if (WARN_ON (!dpmcp_dev))return -EINVAL ; - error =dpmcp_open (mc_io,0 , dpmcp_dev->obj_desc.id, &token); -if (error <0 ) { -dev_err (&dpmcp_dev->dev,"dpmcp_open() failed: %d\n" , error); -return error; - } - - error =dpmcp_reset (mc_io,0 , token); + error =dpmcp_reset (mc_io,0 , dpmcp_dev->mc_handle);if (error <0 ) {dev_err (&dpmcp_dev->dev,"dpmcp_reset() failed: %d\n" , error);return error; } - error =dpmcp_close (mc_io,0 , token); -if (error <0 ) { -dev_err (&dpmcp_dev->dev,"dpmcp_close() failed: %d\n" , error); -return error; - } -return 0 ; }EXPORT_SYMBOL_GPL (fsl_mc_portal_reset);
drivers/staging/fsl-mc/bus/mc-sys.c +67 -7
110 lines not on this page · raw message
drivers/staging/fsl-mc/include/mc-sys.h +5 -0
@@ -69,6 +69,11 @@ int __must_check fsl_create_mc_io(struct device *dev,void fsl_destroy_mc_io (struct fsl_mc_io *mc_io); +int fsl_mc_io_set_dpmcp (struct fsl_mc_io *mc_io, +struct fsl_mc_device *dpmcp_dev); + +void fsl_mc_io_unset_dpmcp (struct fsl_mc_io *mc_io); +int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd);#endif /* _FSL_MC_SYS_H */
--
2.3.3
PATCH v2 4/12 staging: fsl-mc: Changed dev_info() calls to dev_dbg()
In reply to J. German RiveraChanged dev_info() calls to dev_dbg() in fsl_mc_allocator_probe/fsl_mc_allocator_remove, as they are useful only for debugging.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +4 -4
@@ -492,8 +492,8 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)if (error <0 ) goto error; -dev_info (&mc_dev->dev, -"Allocatable MC object device bound to fsl_mc_allocator driver" ); +dev_dbg (&mc_dev->dev, +"Allocatable MC object device bound to fsl_mc_allocator driver" );return 0 ; error:
@@ -515,8 +515,8 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)if (error <0 ) goto out; -dev_info (&mc_dev->dev, -"Allocatable MC object device unbound from fsl_mc_allocator driver" ); +dev_dbg (&mc_dev->dev, +"Allocatable MC object device unbound from fsl_mc_allocator driver" ); error =0 ; out:return error;
--
2.3.3
PATCH v2 5/12 staging_fsl-mc: Changed types of flags, portal size in
In reply to J. German RiveraChanged these two fields from 32-bit integers to 16-bit integers in struct fsl_mc_io, as 32 bits is too much for these fields. This change does not affect other components since fsl_mc_io is an opaque type.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/include/mc-sys.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/fsl-mc/include/mc-sys.h +2 -2
@@ -54,8 +54,8 @@ struct mc_command;*/ struct fsl_mc_io {struct device *dev; -u32 flags; -u32 portal_size; +u16 flags; +u16 portal_size;phys_addr_t portal_phys_addr;void __iomem *portal_virt_addr;struct fsl_mc_device *dpmcp_dev;
--
2.3.3
PATCH v2 6/12 staging: fsl-mc: Removed unused DPMCP macros
In reply to J. German RiveraThe macros were a left-over from a previous implementation of the dpmcp APIs and are no longer used.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/dpmcp-cmd.h | 79 ---------------------------------- 1 file changed, 79 deletions(-)
drivers/staging/fsl-mc/bus/dpmcp-cmd.h +0 -79
@@ -54,83 +54,4 @@#define DPMCP_CMDID_GET_IRQ_STATUS 0x016#define DPMCP_CMDID_CLEAR_IRQ_STATUS 0x017 -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_CREATE (cmd, cfg) \ - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->portal_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_SET_IRQ (cmd, irq_index, irq_addr, irq_val, user_irq_id) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\ - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_val);\ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_addr); \ - MC_CMD_OP(cmd, 2, 0, 32, int, user_irq_id); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_GET_IRQ (cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_RSP_GET_IRQ (cmd, type, irq_addr, irq_val, user_irq_id) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_val); \ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_addr); \ - MC_RSP_OP(cmd, 2, 0, 32, int, user_irq_id); \ - MC_RSP_OP(cmd, 2, 32, 32, int, type); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_SET_IRQ_ENABLE (cmd, irq_index, en) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_GET_IRQ_ENABLE (cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_RSP_GET_IRQ_ENABLE (cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_SET_IRQ_MASK (cmd, irq_index, mask) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_GET_IRQ_MASK (cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_RSP_GET_IRQ_MASK (cmd, mask) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_GET_IRQ_STATUS (cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_RSP_GET_IRQ_STATUS (cmd, status) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_CMD_CLEAR_IRQ_STATUS (cmd, irq_index, status) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMCP_RSP_GET_ATTRIBUTES (cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\ - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\ -} while (0) -#endif /* _FSL_DPMCP_CMD_H */
--
2.3.3
PATCH v2 7/12 staging: fsl-mc: Fixed alignment of copyright comment
In reply to J. German RiveraWhitespace cleanup-- add missing spaces in column 1 of copyright
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/include/dpcon-cmd.h | 60 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/staging/fsl-mc/include/dpcon-cmd.h +30 -30
@@ -1,34 +1,34 @@/* Copyright 2013-2015 Freescale Semiconductor Inc. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the above-listed copyright holders nor the -* names of any contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* -* ALTERNATIVELY, this software may be distributed under the terms of the -* GNU General Public License ("GPL") as published by the Free Software -* Foundation, either version 2 of that License or (at your option) any -* later version. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the above-listed copyright holders nor the +* names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ #ifndef _FSL_DPCON_CMD_H#define _FSL_DPCON_CMD_H
--
2.3.3
PATCH v2 8/12 staging: fsl-mc: Fixed bug in fsl_mc_allocator_remove
In reply to J. German RiveraCall fsl_mc_resource_pool_remove_device() only if mc_dev->resource is not NULL.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +5 -3
@@ -511,9 +511,11 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)if (WARN_ON (!FSL_MC_IS_ALLOCATABLE (mc_dev->obj_desc.type))) goto out; - error =fsl_mc_resource_pool_remove_device (mc_dev); -if (error <0 ) - goto out; +if (mc_dev->resource) { + error =fsl_mc_resource_pool_remove_device (mc_dev); +if (error <0 ) + goto out; + }dev_dbg (&mc_dev->dev,"Allocatable MC object device unbound from fsl_mc_allocator driver" );
--
2.3.3
PATCH v2 9/12 staging: fsl-mc: refactored error exit in allocator probe/remove
In reply to J. German RiveraReplaced error gotos with direct returns in fsl_mc_allocator_probe() and fsl_mc_allocator_remove(), since the only error handling done in those functions is to exit.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +9 -14
@@ -474,30 +474,27 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)enum fsl_mc_pool_type pool_type;struct fsl_mc_device *mc_bus_dev;struct fsl_mc_bus *mc_bus; -int error = -EINVAL ; +int error;if (WARN_ON (!FSL_MC_IS_ALLOCATABLE (mc_dev->obj_desc.type))) - goto error; +return -EINVAL ; mc_bus_dev =to_fsl_mc_device (mc_dev->dev.parent);if (WARN_ON (mc_bus_dev->dev.bus != &fsl_mc_bus_type)) - goto error; +return -EINVAL ; mc_bus =to_fsl_mc_bus (mc_bus_dev); error =object_type_to_pool_type (mc_dev->obj_desc.type, &pool_type);if (error <0 ) - goto error; +return error; error =fsl_mc_resource_pool_add_device (mc_bus, pool_type, mc_dev);if (error <0 ) - goto error; +return error;dev_dbg (&mc_dev->dev,"Allocatable MC object device bound to fsl_mc_allocator driver" );return 0 ; -error: - -return error; }/**
@@ -506,22 +503,20 @@ error:*/ static int fsl_mc_allocator_remove (struct fsl_mc_device *mc_dev) { -int error = -EINVAL ; +int error;if (WARN_ON (!FSL_MC_IS_ALLOCATABLE (mc_dev->obj_desc.type))) - goto out; +return -EINVAL ;if (mc_dev->resource) { error =fsl_mc_resource_pool_remove_device (mc_dev);if (error <0 ) - goto out; +return error; }dev_dbg (&mc_dev->dev,"Allocatable MC object device unbound from fsl_mc_allocator driver" ); - error =0 ; -out: -return error; +return 0 ; }static const struct fsl_mc_device_match_id match_id_table[] = {
--
2.3.3
PATCH v2 10/12 staging: fsl-mc: Fixed WARN_ON() in fsl_mc_resource_pool_remove_device
In reply to J. German RiveraCheck that resource is not NULL before de-referencing it.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-allocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fsl-mc/bus/mc-allocator.c +1 -1
@@ -111,7 +111,7 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device goto out; resource = mc_dev->resource; -if (WARN_ON (resource->data != mc_dev)) +if (WARN_ON (!resource || resource->data != mc_dev)) goto out; mc_bus_dev =to_fsl_mc_device (mc_dev->dev.parent);
--
2.3.3
PATCH v2 11/12 staging: fsl-mc: fixed bug in uninitialized root dprc irq count
In reply to J. German RiveraWhen initializing the object attributes for the root dprc, the irq_count was uninitialized. Initialize it to 1.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-bus.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/fsl-mc/bus/mc-bus.c +1 -0
@@ -749,6 +749,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) obj_desc.id = container_id; obj_desc.ver_major =DPRC_VER_MAJOR ; obj_desc.ver_minor =DPRC_VER_MINOR ; + obj_desc.irq_count =1 ; obj_desc.region_count =0 ; error =fsl_mc_device_add (&obj_desc, mc_io, &pdev->dev, &mc_bus_dev);
--
2.3.3
PATCH v2 12/12 staging: fsl-mc: Added missing initializer in fsl_mc_bus_driver
In reply to J. German Riveraowner needs to be initialized as THIS_MOUDLE.
---
CHANGE HISTORY
Changes in v2: none
drivers/staging/fsl-mc/bus/mc-bus.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/fsl-mc/bus/mc-bus.c +1 -0
@@ -790,6 +790,7 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table);static struct platform_driver fsl_mc_bus_driver = { .driver = { .name ="fsl_mc_bus" , + .owner =THIS_MODULE , .pm =NULL , .of_match_table = fsl_mc_bus_match_table, },
--
2.3.3