This patch translates the 'generic sja1000' enable() calls into platform_device hooks.
Signed-off-by: Kurt Van Dijck <[email protected]> --- Index: include/linux/can/platform/sja1000.h =================================================================== --- include/linux/can/platform/sja1000.h (revision 1066) +++ include/linux/can/platform/sja1000.h (working copy) @@ -25,11 +25,20 @@ #define OCR_TX_MASK 0xfc #define OCR_TX_SHIFT 2 +#include <linux/platform_device.h> + struct sja1000_platform_data { u32 clock; /* CAN bus oscillator frequency in Hz */ u8 ocr; /* output control register */ u8 cdr; /* clock divider register */ + /* + * enable function pointer: + * @pdev : the platform_device, parent of the net_device + * @active : 1 = enable, 0 = disable + * @returns : 0 or -error + */ + int (*enable)(struct platform_device *pdev, int active); }; #endif /* !_CAN_PLATFORM_SJA1000_H_ */ Index: include/socketcan/can/platform/sja1000.h =================================================================== --- include/socketcan/can/platform/sja1000.h (revision 1066) +++ include/socketcan/can/platform/sja1000.h (working copy) @@ -25,11 +25,20 @@ #define OCR_TX_MASK 0xfc #define OCR_TX_SHIFT 2 +#include <linux/platform_device.h> + struct sja1000_platform_data { u32 clock; /* CAN bus oscillator frequency in Hz */ u8 ocr; /* output control register */ u8 cdr; /* clock divider register */ + /* + * enable function pointer: + * @pdev : the platform_device, parent of the net_device + * @active : 1 = enable, 0 = disable + * @returns : 0 or -error + */ + int (*enable)(struct platform_device *pdev, int active); }; #endif /* !_CAN_PLATFORM_SJA1000_H_ */ Index: drivers/net/can/sja1000/sja1000_platform.c =================================================================== --- drivers/net/can/sja1000/sja1000_platform.c (revision 1066) +++ drivers/net/can/sja1000/sja1000_platform.c (working copy) @@ -42,6 +42,12 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus"); MODULE_LICENSE("GPL v2"); +static int sp_enable(struct device *dev, int enable) +{ + struct sja1000_platform_data *pdata = dev->platform_data; + return pdata->enable(to_platform_device(dev), enable); +} + static u8 sp_read_reg(const struct sja1000_priv *priv, int reg) { return ioread8(priv->reg_base + reg); @@ -102,6 +108,12 @@ priv->can.clock.freq = pdata->clock; priv->ocr = pdata->ocr; priv->cdr = pdata->cdr; + /* + * assign (local) enable function + * only when platform_data had it defined too + */ + if (pdata->enable) + priv->enable = sp_enable; dev_set_drvdata(&pdev->dev, dev); SET_NETDEV_DEV(dev, &pdev->dev); _______________________________________________ Socketcan-core mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-core
