diff mbox series

[v2] fpga: remove redundant checks for bridge ops

Message ID 20240201155713.82898-1-marpagan@redhat.com (mailing list archive)
State New
Headers show
Series [v2] fpga: remove redundant checks for bridge ops | expand

Commit Message

Marco Pagani Feb. 1, 2024, 3:57 p.m. UTC
Commit 0d70af3c2530 ("fpga: bridge: Use standard dev_release for class
driver") introduced a check in fpga_bridge_register() that prevents
registering a bridge without ops, making checking on every call
redundant.

v2:
- removed ops check also in state_show()

Signed-off-by: Marco Pagani <marpagan@redhat.com>
---
 drivers/fpga/fpga-bridge.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: c849ecb2ae8413f86c84627cb0af06dffce4e215

Comments

Xu Yilun Feb. 18, 2024, 4:04 a.m. UTC | #1
On Thu, Feb 01, 2024 at 04:57:12PM +0100, Marco Pagani wrote:
> Commit 0d70af3c2530 ("fpga: bridge: Use standard dev_release for class
> driver") introduced a check in fpga_bridge_register() that prevents
> registering a bridge without ops, making checking on every call
> redundant.
> 
> v2:
> - removed ops check also in state_show()

Don't put the history in changelog. 

I could fix it.
Acked-by: Xu Yilun <yilun.xu@intel.com>

> 
> Signed-off-by: Marco Pagani <marpagan@redhat.com>
---
v2:
- XXXX

This way the history could be discarded when apply.

> ---
>  drivers/fpga/fpga-bridge.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
> index a024be2b84e2..79c473b3c7c3 100644
> --- a/drivers/fpga/fpga-bridge.c
> +++ b/drivers/fpga/fpga-bridge.c
> @@ -30,7 +30,7 @@ int fpga_bridge_enable(struct fpga_bridge *bridge)
>  {
>  	dev_dbg(&bridge->dev, "enable\n");
>  
> -	if (bridge->br_ops && bridge->br_ops->enable_set)
> +	if (bridge->br_ops->enable_set)
>  		return bridge->br_ops->enable_set(bridge, 1);
>  
>  	return 0;
> @@ -48,7 +48,7 @@ int fpga_bridge_disable(struct fpga_bridge *bridge)
>  {
>  	dev_dbg(&bridge->dev, "disable\n");
>  
> -	if (bridge->br_ops && bridge->br_ops->enable_set)
> +	if (bridge->br_ops->enable_set)
>  		return bridge->br_ops->enable_set(bridge, 0);
>  
>  	return 0;
> @@ -296,7 +296,7 @@ static ssize_t state_show(struct device *dev,
>  	struct fpga_bridge *bridge = to_fpga_bridge(dev);
>  	int state = 1;
>  
> -	if (bridge->br_ops && bridge->br_ops->enable_show) {
> +	if (bridge->br_ops->enable_show) {
>  		state = bridge->br_ops->enable_show(bridge);
>  		if (state < 0)
>  			return state;
> @@ -401,7 +401,7 @@ void fpga_bridge_unregister(struct fpga_bridge *bridge)
>  	 * If the low level driver provides a method for putting bridge into
>  	 * a desired state upon unregister, do it.
>  	 */
> -	if (bridge->br_ops && bridge->br_ops->fpga_bridge_remove)
> +	if (bridge->br_ops->fpga_bridge_remove)
>  		bridge->br_ops->fpga_bridge_remove(bridge);
>  
>  	device_unregister(&bridge->dev);
> 
> base-commit: c849ecb2ae8413f86c84627cb0af06dffce4e215
> -- 
> 2.43.0
> 
>
Marco Pagani Feb. 20, 2024, 10:25 a.m. UTC | #2
On 2024-02-18 05:04, Xu Yilun wrote:
> On Thu, Feb 01, 2024 at 04:57:12PM +0100, Marco Pagani wrote:
>> Commit 0d70af3c2530 ("fpga: bridge: Use standard dev_release for class
>> driver") introduced a check in fpga_bridge_register() that prevents
>> registering a bridge without ops, making checking on every call
>> redundant.
>>
>> v2:
>> - removed ops check also in state_show()
> 
> Don't put the history in changelog. 

You're right, sorry.

> 
> I could fix it.
> Acked-by: Xu Yilun <yilun.xu@intel.com>
> 

Yes, please.

>>
>> Signed-off-by: Marco Pagani <marpagan@redhat.com>
> ---
> v2:
> - XXXX
> 
> This way the history could be discarded when apply.
> 
>> ---
>>  drivers/fpga/fpga-bridge.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
>> index a024be2b84e2..79c473b3c7c3 100644
>> --- a/drivers/fpga/fpga-bridge.c
>> +++ b/drivers/fpga/fpga-bridge.c

[...]
Thanks,
Marco
diff mbox series

Patch

diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
index a024be2b84e2..79c473b3c7c3 100644
--- a/drivers/fpga/fpga-bridge.c
+++ b/drivers/fpga/fpga-bridge.c
@@ -30,7 +30,7 @@  int fpga_bridge_enable(struct fpga_bridge *bridge)
 {
 	dev_dbg(&bridge->dev, "enable\n");
 
-	if (bridge->br_ops && bridge->br_ops->enable_set)
+	if (bridge->br_ops->enable_set)
 		return bridge->br_ops->enable_set(bridge, 1);
 
 	return 0;
@@ -48,7 +48,7 @@  int fpga_bridge_disable(struct fpga_bridge *bridge)
 {
 	dev_dbg(&bridge->dev, "disable\n");
 
-	if (bridge->br_ops && bridge->br_ops->enable_set)
+	if (bridge->br_ops->enable_set)
 		return bridge->br_ops->enable_set(bridge, 0);
 
 	return 0;
@@ -296,7 +296,7 @@  static ssize_t state_show(struct device *dev,
 	struct fpga_bridge *bridge = to_fpga_bridge(dev);
 	int state = 1;
 
-	if (bridge->br_ops && bridge->br_ops->enable_show) {
+	if (bridge->br_ops->enable_show) {
 		state = bridge->br_ops->enable_show(bridge);
 		if (state < 0)
 			return state;
@@ -401,7 +401,7 @@  void fpga_bridge_unregister(struct fpga_bridge *bridge)
 	 * If the low level driver provides a method for putting bridge into
 	 * a desired state upon unregister, do it.
 	 */
-	if (bridge->br_ops && bridge->br_ops->fpga_bridge_remove)
+	if (bridge->br_ops->fpga_bridge_remove)
 		bridge->br_ops->fpga_bridge_remove(bridge);
 
 	device_unregister(&bridge->dev);