Commit fce5c293 authored by Jingoo Han's avatar Jingoo Han Committed by David S. Miller

net: can: mcp251x: use spi_get_drvdata() and spi_set_drvdata()

Use the wrapper functions for getting and setting the driver data using
spi_device instead of using dev_{get|set}_drvdata with &spi->dev, so we
can directly pass a struct spi_device.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4fa0a0ef
...@@ -269,7 +269,7 @@ struct mcp251x_priv { ...@@ -269,7 +269,7 @@ struct mcp251x_priv {
#define MCP251X_IS(_model) \ #define MCP251X_IS(_model) \
static inline int mcp251x_is_##_model(struct spi_device *spi) \ static inline int mcp251x_is_##_model(struct spi_device *spi) \
{ \ { \
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); \ struct mcp251x_priv *priv = spi_get_drvdata(spi); \
return priv->model == CAN_MCP251X_MCP##_model; \ return priv->model == CAN_MCP251X_MCP##_model; \
} }
...@@ -305,7 +305,7 @@ static void mcp251x_clean(struct net_device *net) ...@@ -305,7 +305,7 @@ static void mcp251x_clean(struct net_device *net)
*/ */
static int mcp251x_spi_trans(struct spi_device *spi, int len) static int mcp251x_spi_trans(struct spi_device *spi, int len)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
struct spi_transfer t = { struct spi_transfer t = {
.tx_buf = priv->spi_tx_buf, .tx_buf = priv->spi_tx_buf,
.rx_buf = priv->spi_rx_buf, .rx_buf = priv->spi_rx_buf,
...@@ -333,7 +333,7 @@ static int mcp251x_spi_trans(struct spi_device *spi, int len) ...@@ -333,7 +333,7 @@ static int mcp251x_spi_trans(struct spi_device *spi, int len)
static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg) static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
u8 val = 0; u8 val = 0;
priv->spi_tx_buf[0] = INSTRUCTION_READ; priv->spi_tx_buf[0] = INSTRUCTION_READ;
...@@ -348,7 +348,7 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg) ...@@ -348,7 +348,7 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg)
static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg, static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg,
uint8_t *v1, uint8_t *v2) uint8_t *v1, uint8_t *v2)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
priv->spi_tx_buf[0] = INSTRUCTION_READ; priv->spi_tx_buf[0] = INSTRUCTION_READ;
priv->spi_tx_buf[1] = reg; priv->spi_tx_buf[1] = reg;
...@@ -361,7 +361,7 @@ static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg, ...@@ -361,7 +361,7 @@ static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg,
static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val) static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
priv->spi_tx_buf[0] = INSTRUCTION_WRITE; priv->spi_tx_buf[0] = INSTRUCTION_WRITE;
priv->spi_tx_buf[1] = reg; priv->spi_tx_buf[1] = reg;
...@@ -373,7 +373,7 @@ static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val) ...@@ -373,7 +373,7 @@ static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val)
static void mcp251x_write_bits(struct spi_device *spi, u8 reg, static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
u8 mask, uint8_t val) u8 mask, uint8_t val)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
priv->spi_tx_buf[0] = INSTRUCTION_BIT_MODIFY; priv->spi_tx_buf[0] = INSTRUCTION_BIT_MODIFY;
priv->spi_tx_buf[1] = reg; priv->spi_tx_buf[1] = reg;
...@@ -386,7 +386,7 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg, ...@@ -386,7 +386,7 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
int len, int tx_buf_idx) int len, int tx_buf_idx)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
if (mcp251x_is_2510(spi)) { if (mcp251x_is_2510(spi)) {
int i; int i;
...@@ -403,7 +403,7 @@ static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, ...@@ -403,7 +403,7 @@ static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame,
int tx_buf_idx) int tx_buf_idx)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
u32 sid, eid, exide, rtr; u32 sid, eid, exide, rtr;
u8 buf[SPI_TRANSFER_BUF_LEN]; u8 buf[SPI_TRANSFER_BUF_LEN];
...@@ -434,7 +434,7 @@ static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, ...@@ -434,7 +434,7 @@ static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame,
static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
int buf_idx) int buf_idx)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
if (mcp251x_is_2510(spi)) { if (mcp251x_is_2510(spi)) {
int i, len; int i, len;
...@@ -454,7 +454,7 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, ...@@ -454,7 +454,7 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx) static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
struct sk_buff *skb; struct sk_buff *skb;
struct can_frame *frame; struct can_frame *frame;
u8 buf[SPI_TRANSFER_BUF_LEN]; u8 buf[SPI_TRANSFER_BUF_LEN];
...@@ -550,7 +550,7 @@ static int mcp251x_do_set_mode(struct net_device *net, enum can_mode mode) ...@@ -550,7 +550,7 @@ static int mcp251x_do_set_mode(struct net_device *net, enum can_mode mode)
static int mcp251x_set_normal_mode(struct spi_device *spi) static int mcp251x_set_normal_mode(struct spi_device *spi)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
unsigned long timeout; unsigned long timeout;
/* Enable interrupts */ /* Enable interrupts */
...@@ -620,7 +620,7 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv, ...@@ -620,7 +620,7 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv,
static int mcp251x_hw_reset(struct spi_device *spi) static int mcp251x_hw_reset(struct spi_device *spi)
{ {
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
int ret; int ret;
unsigned long timeout; unsigned long timeout;
...@@ -1020,7 +1020,7 @@ static int mcp251x_can_probe(struct spi_device *spi) ...@@ -1020,7 +1020,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
priv->model = spi_get_device_id(spi)->driver_data; priv->model = spi_get_device_id(spi)->driver_data;
priv->net = net; priv->net = net;
dev_set_drvdata(&spi->dev, priv); spi_set_drvdata(spi, priv);
priv->spi = spi; priv->spi = spi;
mutex_init(&priv->mcp_lock); mutex_init(&priv->mcp_lock);
...@@ -1118,7 +1118,7 @@ static int mcp251x_can_probe(struct spi_device *spi) ...@@ -1118,7 +1118,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
static int mcp251x_can_remove(struct spi_device *spi) static int mcp251x_can_remove(struct spi_device *spi)
{ {
struct mcp251x_platform_data *pdata = spi->dev.platform_data; struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
struct net_device *net = priv->net; struct net_device *net = priv->net;
unregister_candev(net); unregister_candev(net);
...@@ -1144,7 +1144,7 @@ static int mcp251x_can_suspend(struct device *dev) ...@@ -1144,7 +1144,7 @@ static int mcp251x_can_suspend(struct device *dev)
{ {
struct spi_device *spi = to_spi_device(dev); struct spi_device *spi = to_spi_device(dev);
struct mcp251x_platform_data *pdata = spi->dev.platform_data; struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
struct net_device *net = priv->net; struct net_device *net = priv->net;
priv->force_quit = 1; priv->force_quit = 1;
...@@ -1176,7 +1176,7 @@ static int mcp251x_can_resume(struct device *dev) ...@@ -1176,7 +1176,7 @@ static int mcp251x_can_resume(struct device *dev)
{ {
struct spi_device *spi = to_spi_device(dev); struct spi_device *spi = to_spi_device(dev);
struct mcp251x_platform_data *pdata = spi->dev.platform_data; struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); struct mcp251x_priv *priv = spi_get_drvdata(spi);
if (priv->after_suspend & AFTER_SUSPEND_POWER) { if (priv->after_suspend & AFTER_SUSPEND_POWER) {
pdata->power_enable(1); pdata->power_enable(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment