linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: can: c_can: use proper type for 'instance'
@ 2014-04-17  8:57 Wolfram Sang
  2014-04-17 19:22 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2014-04-17  8:57 UTC (permalink / raw)
  To: linux-can; +Cc: Wolfram Sang, Chen Gang, Wolfgang Grandegger, Marc Kleine-Budde

From: Wolfram Sang <wsa@sang-engineering.com>

Commit 6439fbce1075 (can: c_can: fix error checking of priv->instance in
probe()) found the warning but applied a suboptimal solution. Since, both
pdev->id and of_alias_get_id() return integers, it makes sense to convert the
variable to an integer and avoid the cast.

Signed-off-by: Wolfram Sang <wsa@sang-engineering.com>
---

@chen: casts are rarely the correct solution. Please always investigate further
before applying them

 drivers/net/can/c_can/c_can.h          | 2 +-
 drivers/net/can/c_can/c_can_platform.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index faa8404162b3..308601c6c0d7 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -198,7 +198,7 @@ struct c_can_priv {
 	u16 irqstatus;
 	enum c_can_dev_id type;
 	u32 __iomem *raminit_ctrlreg;
-	unsigned int instance;
+	int instance;
 	void (*raminit) (const struct c_can_priv *priv, bool enable);
 	u32 dlc[C_CAN_MSG_OBJ_TX_NUM];
 };
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 806d92753427..1df0b322d1e4 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -222,7 +222,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 		priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res);
-		if (IS_ERR(priv->raminit_ctrlreg) || (int)priv->instance < 0)
+		if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
 			dev_info(&pdev->dev, "control memory is not used for raminit\n");
 		else
 			priv->raminit = c_can_hw_raminit;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: can: c_can: use proper type for 'instance'
  2014-04-17  8:57 [PATCH] net: can: c_can: use proper type for 'instance' Wolfram Sang
@ 2014-04-17 19:22 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2014-04-17 19:22 UTC (permalink / raw)
  To: Wolfram Sang, linux-can; +Cc: Chen Gang, Wolfgang Grandegger

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

On 04/17/2014 10:57 AM, Wolfram Sang wrote:
> From: Wolfram Sang <wsa@sang-engineering.com>
> 
> Commit 6439fbce1075 (can: c_can: fix error checking of priv->instance in
> probe()) found the warning but applied a suboptimal solution. Since, both
> pdev->id and of_alias_get_id() return integers, it makes sense to convert the
> variable to an integer and avoid the cast.
> 
> Signed-off-by: Wolfram Sang <wsa@sang-engineering.com>

Applied to can/master.

Thanks,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-17 19:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17  8:57 [PATCH] net: can: c_can: use proper type for 'instance' Wolfram Sang
2014-04-17 19:22 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).