aboutsummaryrefslogtreecommitdiffstats
path: root/pwm-internal.h
blob: 0489aaa07b8789caa8bc93c19915324d7bc5e9cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* SPDX-License-Identifier: LGPL-2.1-only */
/* SPDX-FileCopyrightText: 2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> */

#include <pwm.h>

#define container_of(ptr, type, member) ({				\
	(type *)((void *)(ptr) - __builtin_offsetof(type, member)); })

struct pwm_chip {
	unsigned int npwm;
	void (*close)(struct pwm_chip *chip);
	struct pwm *(*get_pwm)(struct pwm_chip *chip, unsigned int offset);
	int (*apply_state)(struct pwm *pwm, const struct pwm_state *state);
	int (*get_state)(struct pwm *pwm, struct pwm_state *state);
};

struct pwm {
	struct pwm_chip *chip;
};

struct pwm_chip *pwm_chip_cdev_open_by_number(unsigned int num);
struct pwm_chip *pwm_chip_sysfs_open_by_number(unsigned int num);