gpio: mc9s08dz60: use gpiochip data pointer
This makes the driver use the data pointer added to the gpio_chip to store a pointer to the state container instead of relying on container_of(). Cc: wu guoxing <b39297@freescale.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
609f9692cc
commit
cf90c9e35b
1 changed files with 4 additions and 10 deletions
|
@ -29,12 +29,6 @@ struct mc9s08dz60 {
|
||||||
struct gpio_chip chip;
|
struct gpio_chip chip;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct mc9s08dz60 *to_mc9s08dz60(struct gpio_chip *gc)
|
|
||||||
{
|
|
||||||
return container_of(gc, struct mc9s08dz60, chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void mc9s_gpio_to_reg_and_bit(int offset, u8 *reg, u8 *bit)
|
static void mc9s_gpio_to_reg_and_bit(int offset, u8 *reg, u8 *bit)
|
||||||
{
|
{
|
||||||
*reg = 0x20 + offset / GPIO_NUM_PER_GROUP;
|
*reg = 0x20 + offset / GPIO_NUM_PER_GROUP;
|
||||||
|
@ -45,7 +39,7 @@ static int mc9s08dz60_get_value(struct gpio_chip *gc, unsigned offset)
|
||||||
{
|
{
|
||||||
u8 reg, bit;
|
u8 reg, bit;
|
||||||
s32 value;
|
s32 value;
|
||||||
struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc);
|
struct mc9s08dz60 *mc9s = gpiochip_get_data(gc);
|
||||||
|
|
||||||
mc9s_gpio_to_reg_and_bit(offset, ®, &bit);
|
mc9s_gpio_to_reg_and_bit(offset, ®, &bit);
|
||||||
value = i2c_smbus_read_byte_data(mc9s->client, reg);
|
value = i2c_smbus_read_byte_data(mc9s->client, reg);
|
||||||
|
@ -75,7 +69,7 @@ static int mc9s08dz60_set(struct mc9s08dz60 *mc9s, unsigned offset, int val)
|
||||||
|
|
||||||
static void mc9s08dz60_set_value(struct gpio_chip *gc, unsigned offset, int val)
|
static void mc9s08dz60_set_value(struct gpio_chip *gc, unsigned offset, int val)
|
||||||
{
|
{
|
||||||
struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc);
|
struct mc9s08dz60 *mc9s = gpiochip_get_data(gc);
|
||||||
|
|
||||||
mc9s08dz60_set(mc9s, offset, val);
|
mc9s08dz60_set(mc9s, offset, val);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +77,7 @@ static void mc9s08dz60_set_value(struct gpio_chip *gc, unsigned offset, int val)
|
||||||
static int mc9s08dz60_direction_output(struct gpio_chip *gc,
|
static int mc9s08dz60_direction_output(struct gpio_chip *gc,
|
||||||
unsigned offset, int val)
|
unsigned offset, int val)
|
||||||
{
|
{
|
||||||
struct mc9s08dz60 *mc9s = to_mc9s08dz60(gc);
|
struct mc9s08dz60 *mc9s = gpiochip_get_data(gc);
|
||||||
|
|
||||||
return mc9s08dz60_set(mc9s, offset, val);
|
return mc9s08dz60_set(mc9s, offset, val);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +103,7 @@ static int mc9s08dz60_probe(struct i2c_client *client,
|
||||||
mc9s->client = client;
|
mc9s->client = client;
|
||||||
i2c_set_clientdata(client, mc9s);
|
i2c_set_clientdata(client, mc9s);
|
||||||
|
|
||||||
return gpiochip_add(&mc9s->chip);
|
return gpiochip_add_data(&mc9s->chip, mc9s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mc9s08dz60_remove(struct i2c_client *client)
|
static int mc9s08dz60_remove(struct i2c_client *client)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue