static int nct5104d_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{
int err;
- struct nct5104d_gpio_bank *bank =
- container_of(chip, struct nct5104d_gpio_bank, chip);
+ struct nct5104d_gpio_bank *bank = gpiochip_get_data(chip);
struct nct5104d_sio *sio = bank->data->sio;
u8 dir;
static int nct5104d_gpio_get(struct gpio_chip *chip, unsigned offset)
{
int err;
- struct nct5104d_gpio_bank *bank =
- container_of(chip, struct nct5104d_gpio_bank, chip);
+ struct nct5104d_gpio_bank *bank = gpiochip_get_data(chip);
struct nct5104d_sio *sio = bank->data->sio;
u8 data;
unsigned offset, int value)
{
int err;
- struct nct5104d_gpio_bank *bank =
- container_of(chip, struct nct5104d_gpio_bank, chip);
+ struct nct5104d_gpio_bank *bank = gpiochip_get_data(chip);
struct nct5104d_sio *sio = bank->data->sio;
u8 dir, data_out;
static void nct5104d_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
int err;
- struct nct5104d_gpio_bank *bank =
- container_of(chip, struct nct5104d_gpio_bank, chip);
+ struct nct5104d_gpio_bank *bank = gpiochip_get_data(chip);
struct nct5104d_sio *sio = bank->data->sio;
u8 data_out;
}
data->sio = sio;
- platform_set_drvdata(pdev, data);
-
/* For each GPIO bank, register a GPIO chip. */
for (i = 0; i < data->nr_bank; i++) {
struct nct5104d_gpio_bank *bank = &data->bank[i];
bank->chip.parent = &pdev->dev;
bank->data = data;
- err = gpiochip_add(&bank->chip);
- if (err) {
- dev_err(&pdev->dev,
- "Failed to register gpiochip %d: %d\n",
- i, err);
- goto err_gpiochip;
- }
- }
-
- return 0;
-
-err_gpiochip:
- for (i = i - 1; i >= 0; i--) {
- struct nct5104d_gpio_bank *bank = &data->bank[i];
-
- gpiochip_remove (&bank->chip);
- }
-
- return err;
-}
-
-static int nct5104d_gpio_remove(struct platform_device *pdev)
-{
- int i;
- struct nct5104d_gpio_data *data = platform_get_drvdata(pdev);
-
- for (i = 0; i < data->nr_bank; i++) {
- struct nct5104d_gpio_bank *bank = &data->bank[i];
-
- gpiochip_remove (&bank->chip);
+ err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank);
+ if (err)
+ return dev_err_probe(&pdev->dev, err,
+ "Failed to register gpiochip %d", err);
}
return 0;
.name = DRVNAME,
},
.probe = nct5104d_gpio_probe,
- .remove = nct5104d_gpio_remove,
};
static int __init nct5104d_gpio_init(void)