Skip to content

Commit

Permalink
siflower: gpio: use gpiochip_get_data
Browse files Browse the repository at this point in the history
No need to use container_of.

Signed-off-by: Rosen Penev <[email protected]>
Link: openwrt#16749
Signed-off-by: Chuanhong Guo <[email protected]>
  • Loading branch information
neheb authored and 981213 committed Oct 21, 2024
1 parent e550c6d commit f9da81d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions target/linux/siflower/files-6.6/drivers/gpio/gpio-siflower.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ struct sf_gpio_priv {
unsigned int irq[];
};

#define to_sf_gpio(x) container_of(x, struct sf_gpio_priv, gc)

static u32 sf_gpio_rd(struct sf_gpio_priv *priv, unsigned long reg)
{
return readl_relaxed(priv->base + reg);
Expand All @@ -44,22 +42,22 @@ static void sf_gpio_wr(struct sf_gpio_priv *priv, unsigned long reg,

static int sf_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);

return sf_gpio_rd(priv, GPIO_IR(offset));
}

static void sf_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);

sf_gpio_wr(priv, GPIO_OR(offset), value);
}

static int sf_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);

if (sf_gpio_rd(priv, GPIO_OEN(offset)))
return GPIO_LINE_DIRECTION_IN;
Expand All @@ -69,7 +67,7 @@ static int sf_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)

static int sf_gpio_direction_input(struct gpio_chip *gc, unsigned int offset)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);

sf_gpio_wr(priv, GPIO_OEN(offset), 1);
return 0;
Expand All @@ -78,7 +76,7 @@ static int sf_gpio_direction_input(struct gpio_chip *gc, unsigned int offset)
static int sf_gpio_direction_output(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);

sf_gpio_wr(priv, GPIO_OR(offset), value);
sf_gpio_wr(priv, GPIO_OEN(offset), 0);
Expand All @@ -88,7 +86,7 @@ static int sf_gpio_direction_output(struct gpio_chip *gc, unsigned int offset,
static int sf_gpio_set_debounce(struct gpio_chip *gc, unsigned int offset,
u32 debounce)
{
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long freq = clk_get_rate(priv->clk);
u64 mul;

Expand Down Expand Up @@ -119,7 +117,7 @@ static int sf_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
static void sf_gpio_irq_ack(struct irq_data *data)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long offset = irqd_to_hwirq(data);

sf_gpio_wr(priv, GPIO_PIR(offset), 0);
Expand All @@ -128,7 +126,7 @@ static void sf_gpio_irq_ack(struct irq_data *data)
static void sf_gpio_irq_mask(struct irq_data *data)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long offset = irqd_to_hwirq(data);

sf_gpio_wr(priv, GPIO_IMR(offset), 1);
Expand All @@ -138,7 +136,7 @@ static void sf_gpio_irq_mask(struct irq_data *data)
static void sf_gpio_irq_unmask(struct irq_data *data)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long offset = irqd_to_hwirq(data);

sf_gpio_wr(priv, GPIO_IMR(offset), 0);
Expand Down Expand Up @@ -183,7 +181,7 @@ static int sf_gpio_irq_set_affinity(struct irq_data *data,
static int sf_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned long offset = irqd_to_hwirq(data);
u32 val;

Expand Down Expand Up @@ -231,7 +229,7 @@ static void sf_gpio_irq_handler(struct irq_desc *desc)
{
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
struct irq_chip *ic = irq_desc_get_chip(desc);
struct sf_gpio_priv *priv = to_sf_gpio(gc);
struct sf_gpio_priv *priv = gpiochip_get_data(gc);
unsigned int irq = irq_desc_get_irq(desc);
unsigned int group = irq - priv->irq[0];
unsigned long pending;
Expand Down

0 comments on commit f9da81d

Please sign in to comment.