- u32 val;
- u32 mask;
-
- mask = 1 << gpio;
-
- spin_lock(&gpio_lock);
- val = LOONGSON_GPIODATA;
- if (value)
- val |= mask;
- else
- val &= (~mask);
- LOONGSON_GPIODATA = val;
- spin_unlock(&gpio_lock);
+ struct gpio_chip *gc;
+ struct device *dev = &pdev->dev;
+
+ gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
+ if (!gc)
+ return -ENOMEM;
+
+ gc->label = "loongson-gpio-chip";
+ gc->base = 0;
+ gc->ngpio = LOONGSON_N_GPIO;
+ gc->get = loongson_gpio_get_value;
+ gc->set = loongson_gpio_set_value;
+ gc->direction_input = loongson_gpio_direction_input;
+ gc->direction_output = loongson_gpio_direction_output;
+
+ return gpiochip_add_data(gc, NULL);