Commit 9608405b authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: samsung: Consistently use the same name for driver data

The driver uses mostly "chip" to name samsung_pwm_chip pointers:

$ git grep -Pho 'samsung_pwm_chip \*[a-zA-Z0-9_]+(*nla:[a-zA-Z0-9_(])' v6.5-rc1 -- drivers/pwm/pwm-samsung.c | sort | uniq -c
     10 samsung_pwm_chip *chip
      6 samsung_pwm_chip *our_chip
      1 samsung_pwm_chip *pwm

However "chip" is supposed to be used for struct pwm_chip pointers and
"pwm" for struct pwm_device pointers. So consistently use "our_chip".

Link: https://lore.kernel.org/r/20230929161918.2410424-11-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent dfbf9379
...@@ -118,21 +118,21 @@ static inline unsigned int to_tcon_channel(unsigned int channel) ...@@ -118,21 +118,21 @@ static inline unsigned int to_tcon_channel(unsigned int channel)
return (channel == 0) ? 0 : (channel + 1); return (channel == 0) ? 0 : (channel + 1);
} }
static void __pwm_samsung_manual_update(struct samsung_pwm_chip *chip, static void __pwm_samsung_manual_update(struct samsung_pwm_chip *our_chip,
struct pwm_device *pwm) struct pwm_device *pwm)
{ {
unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm);
u32 tcon; u32 tcon;
tcon = readl(chip->base + REG_TCON); tcon = readl(our_chip->base + REG_TCON);
tcon |= TCON_MANUALUPDATE(tcon_chan); tcon |= TCON_MANUALUPDATE(tcon_chan);
writel(tcon, chip->base + REG_TCON); writel(tcon, our_chip->base + REG_TCON);
tcon &= ~TCON_MANUALUPDATE(tcon_chan); tcon &= ~TCON_MANUALUPDATE(tcon_chan);
writel(tcon, chip->base + REG_TCON); writel(tcon, our_chip->base + REG_TCON);
} }
static void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm, static void pwm_samsung_set_divisor(struct samsung_pwm_chip *our_chip,
unsigned int channel, u8 divisor) unsigned int channel, u8 divisor)
{ {
u8 shift = TCFG1_SHIFT(channel); u8 shift = TCFG1_SHIFT(channel);
...@@ -140,39 +140,39 @@ static void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm, ...@@ -140,39 +140,39 @@ static void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm,
u32 reg; u32 reg;
u8 bits; u8 bits;
bits = (fls(divisor) - 1) - pwm->variant.div_base; bits = (fls(divisor) - 1) - our_chip->variant.div_base;
spin_lock_irqsave(&samsung_pwm_lock, flags); spin_lock_irqsave(&samsung_pwm_lock, flags);
reg = readl(pwm->base + REG_TCFG1); reg = readl(our_chip->base + REG_TCFG1);
reg &= ~(TCFG1_MUX_MASK << shift); reg &= ~(TCFG1_MUX_MASK << shift);
reg |= bits << shift; reg |= bits << shift;
writel(reg, pwm->base + REG_TCFG1); writel(reg, our_chip->base + REG_TCFG1);
spin_unlock_irqrestore(&samsung_pwm_lock, flags); spin_unlock_irqrestore(&samsung_pwm_lock, flags);
} }
static int pwm_samsung_is_tdiv(struct samsung_pwm_chip *chip, unsigned int chan) static int pwm_samsung_is_tdiv(struct samsung_pwm_chip *our_chip, unsigned int chan)
{ {
struct samsung_pwm_variant *variant = &chip->variant; struct samsung_pwm_variant *variant = &our_chip->variant;
u32 reg; u32 reg;
reg = readl(chip->base + REG_TCFG1); reg = readl(our_chip->base + REG_TCFG1);
reg >>= TCFG1_SHIFT(chan); reg >>= TCFG1_SHIFT(chan);
reg &= TCFG1_MUX_MASK; reg &= TCFG1_MUX_MASK;
return (BIT(reg) & variant->tclk_mask) == 0; return (BIT(reg) & variant->tclk_mask) == 0;
} }
static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *chip, static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *our_chip,
unsigned int chan) unsigned int chan)
{ {
unsigned long rate; unsigned long rate;
u32 reg; u32 reg;
rate = clk_get_rate(chip->base_clk); rate = clk_get_rate(our_chip->base_clk);
reg = readl(chip->base + REG_TCFG0); reg = readl(our_chip->base + REG_TCFG0);
if (chan >= 2) if (chan >= 2)
reg >>= TCFG0_PRESCALER1_SHIFT; reg >>= TCFG0_PRESCALER1_SHIFT;
reg &= TCFG0_PRESCALER_MASK; reg &= TCFG0_PRESCALER_MASK;
...@@ -180,28 +180,28 @@ static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *chip, ...@@ -180,28 +180,28 @@ static unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *chip,
return rate / (reg + 1); return rate / (reg + 1);
} }
static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *chip, static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *our_chip,
unsigned int chan, unsigned long freq) unsigned int chan, unsigned long freq)
{ {
struct samsung_pwm_variant *variant = &chip->variant; struct samsung_pwm_variant *variant = &our_chip->variant;
unsigned long rate; unsigned long rate;
struct clk *clk; struct clk *clk;
u8 div; u8 div;
if (!pwm_samsung_is_tdiv(chip, chan)) { if (!pwm_samsung_is_tdiv(our_chip, chan)) {
clk = (chan < 2) ? chip->tclk0 : chip->tclk1; clk = (chan < 2) ? our_chip->tclk0 : our_chip->tclk1;
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
rate = clk_get_rate(clk); rate = clk_get_rate(clk);
if (rate) if (rate)
return rate; return rate;
} }
dev_warn(chip->chip.dev, dev_warn(our_chip->chip.dev,
"tclk of PWM %d is inoperational, using tdiv\n", chan); "tclk of PWM %d is inoperational, using tdiv\n", chan);
} }
rate = pwm_samsung_get_tin_rate(chip, chan); rate = pwm_samsung_get_tin_rate(our_chip, chan);
dev_dbg(chip->chip.dev, "tin parent at %lu\n", rate); dev_dbg(our_chip->chip.dev, "tin parent at %lu\n", rate);
/* /*
* Compare minimum PWM frequency that can be achieved with possible * Compare minimum PWM frequency that can be achieved with possible
...@@ -221,7 +221,7 @@ static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *chip, ...@@ -221,7 +221,7 @@ static unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *chip,
div = variant->div_base; div = variant->div_base;
} }
pwm_samsung_set_divisor(chip, chan, BIT(div)); pwm_samsung_set_divisor(our_chip, chan, BIT(div));
return rate >> div; return rate >> div;
} }
...@@ -293,14 +293,14 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -293,14 +293,14 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm)
spin_unlock_irqrestore(&samsung_pwm_lock, flags); spin_unlock_irqrestore(&samsung_pwm_lock, flags);
} }
static void pwm_samsung_manual_update(struct samsung_pwm_chip *chip, static void pwm_samsung_manual_update(struct samsung_pwm_chip *our_chip,
struct pwm_device *pwm) struct pwm_device *pwm)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&samsung_pwm_lock, flags); spin_lock_irqsave(&samsung_pwm_lock, flags);
__pwm_samsung_manual_update(chip, pwm); __pwm_samsung_manual_update(our_chip, pwm);
spin_unlock_irqrestore(&samsung_pwm_lock, flags); spin_unlock_irqrestore(&samsung_pwm_lock, flags);
} }
...@@ -384,7 +384,7 @@ static int pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -384,7 +384,7 @@ static int pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm,
return __pwm_samsung_config(chip, pwm, duty_ns, period_ns, false); return __pwm_samsung_config(chip, pwm, duty_ns, period_ns, false);
} }
static void pwm_samsung_set_invert(struct samsung_pwm_chip *chip, static void pwm_samsung_set_invert(struct samsung_pwm_chip *our_chip,
unsigned int channel, bool invert) unsigned int channel, bool invert)
{ {
unsigned int tcon_chan = to_tcon_channel(channel); unsigned int tcon_chan = to_tcon_channel(channel);
...@@ -393,17 +393,17 @@ static void pwm_samsung_set_invert(struct samsung_pwm_chip *chip, ...@@ -393,17 +393,17 @@ static void pwm_samsung_set_invert(struct samsung_pwm_chip *chip,
spin_lock_irqsave(&samsung_pwm_lock, flags); spin_lock_irqsave(&samsung_pwm_lock, flags);
tcon = readl(chip->base + REG_TCON); tcon = readl(our_chip->base + REG_TCON);
if (invert) { if (invert) {
chip->inverter_mask |= BIT(channel); our_chip->inverter_mask |= BIT(channel);
tcon |= TCON_INVERT(tcon_chan); tcon |= TCON_INVERT(tcon_chan);
} else { } else {
chip->inverter_mask &= ~BIT(channel); our_chip->inverter_mask &= ~BIT(channel);
tcon &= ~TCON_INVERT(tcon_chan); tcon &= ~TCON_INVERT(tcon_chan);
} }
writel(tcon, chip->base + REG_TCON); writel(tcon, our_chip->base + REG_TCON);
spin_unlock_irqrestore(&samsung_pwm_lock, flags); spin_unlock_irqrestore(&samsung_pwm_lock, flags);
} }
...@@ -506,9 +506,9 @@ static const struct of_device_id samsung_pwm_matches[] = { ...@@ -506,9 +506,9 @@ static const struct of_device_id samsung_pwm_matches[] = {
}; };
MODULE_DEVICE_TABLE(of, samsung_pwm_matches); MODULE_DEVICE_TABLE(of, samsung_pwm_matches);
static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip)
{ {
struct device_node *np = chip->chip.dev->of_node; struct device_node *np = our_chip->chip.dev->of_node;
const struct of_device_id *match; const struct of_device_id *match;
struct property *prop; struct property *prop;
const __be32 *cur; const __be32 *cur;
...@@ -518,22 +518,22 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) ...@@ -518,22 +518,22 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip)
if (!match) if (!match)
return -ENODEV; return -ENODEV;
memcpy(&chip->variant, match->data, sizeof(chip->variant)); memcpy(&our_chip->variant, match->data, sizeof(our_chip->variant));
of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) {
if (val >= SAMSUNG_PWM_NUM) { if (val >= SAMSUNG_PWM_NUM) {
dev_err(chip->chip.dev, dev_err(our_chip->chip.dev,
"%s: invalid channel index in samsung,pwm-outputs property\n", "%s: invalid channel index in samsung,pwm-outputs property\n",
__func__); __func__);
continue; continue;
} }
chip->variant.output_mask |= BIT(val); our_chip->variant.output_mask |= BIT(val);
} }
return 0; return 0;
} }
#else #else
static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) static int pwm_samsung_parse_dt(struct samsung_pwm_chip *our_chip)
{ {
return -ENODEV; return -ENODEV;
} }
...@@ -542,21 +542,21 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) ...@@ -542,21 +542,21 @@ static int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip)
static int pwm_samsung_probe(struct platform_device *pdev) static int pwm_samsung_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct samsung_pwm_chip *chip; struct samsung_pwm_chip *our_chip;
unsigned int chan; unsigned int chan;
int ret; int ret;
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); our_chip = devm_kzalloc(&pdev->dev, sizeof(*our_chip), GFP_KERNEL);
if (chip == NULL) if (our_chip == NULL)
return -ENOMEM; return -ENOMEM;
chip->chip.dev = &pdev->dev; our_chip->chip.dev = &pdev->dev;
chip->chip.ops = &pwm_samsung_ops; our_chip->chip.ops = &pwm_samsung_ops;
chip->chip.npwm = SAMSUNG_PWM_NUM; our_chip->chip.npwm = SAMSUNG_PWM_NUM;
chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; our_chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1;
if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
ret = pwm_samsung_parse_dt(chip); ret = pwm_samsung_parse_dt(our_chip);
if (ret) if (ret)
return ret; return ret;
} else { } else {
...@@ -565,58 +565,58 @@ static int pwm_samsung_probe(struct platform_device *pdev) ...@@ -565,58 +565,58 @@ static int pwm_samsung_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
memcpy(&chip->variant, pdev->dev.platform_data, memcpy(&our_chip->variant, pdev->dev.platform_data,
sizeof(chip->variant)); sizeof(our_chip->variant));
} }
chip->base = devm_platform_ioremap_resource(pdev, 0); our_chip->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(chip->base)) if (IS_ERR(our_chip->base))
return PTR_ERR(chip->base); return PTR_ERR(our_chip->base);
chip->base_clk = devm_clk_get(&pdev->dev, "timers"); our_chip->base_clk = devm_clk_get(&pdev->dev, "timers");
if (IS_ERR(chip->base_clk)) { if (IS_ERR(our_chip->base_clk)) {
dev_err(dev, "failed to get timer base clk\n"); dev_err(dev, "failed to get timer base clk\n");
return PTR_ERR(chip->base_clk); return PTR_ERR(our_chip->base_clk);
} }
ret = clk_prepare_enable(chip->base_clk); ret = clk_prepare_enable(our_chip->base_clk);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to enable base clock\n"); dev_err(dev, "failed to enable base clock\n");
return ret; return ret;
} }
for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan) for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan)
if (chip->variant.output_mask & BIT(chan)) if (our_chip->variant.output_mask & BIT(chan))
pwm_samsung_set_invert(chip, chan, true); pwm_samsung_set_invert(our_chip, chan, true);
/* Following clocks are optional. */ /* Following clocks are optional. */
chip->tclk0 = devm_clk_get(&pdev->dev, "pwm-tclk0"); our_chip->tclk0 = devm_clk_get(&pdev->dev, "pwm-tclk0");
chip->tclk1 = devm_clk_get(&pdev->dev, "pwm-tclk1"); our_chip->tclk1 = devm_clk_get(&pdev->dev, "pwm-tclk1");
platform_set_drvdata(pdev, chip); platform_set_drvdata(pdev, our_chip);
ret = pwmchip_add(&chip->chip); ret = pwmchip_add(&our_chip->chip);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to register PWM chip\n"); dev_err(dev, "failed to register PWM chip\n");
clk_disable_unprepare(chip->base_clk); clk_disable_unprepare(our_chip->base_clk);
return ret; return ret;
} }
dev_dbg(dev, "base_clk at %lu, tclk0 at %lu, tclk1 at %lu\n", dev_dbg(dev, "base_clk at %lu, tclk0 at %lu, tclk1 at %lu\n",
clk_get_rate(chip->base_clk), clk_get_rate(our_chip->base_clk),
!IS_ERR(chip->tclk0) ? clk_get_rate(chip->tclk0) : 0, !IS_ERR(our_chip->tclk0) ? clk_get_rate(our_chip->tclk0) : 0,
!IS_ERR(chip->tclk1) ? clk_get_rate(chip->tclk1) : 0); !IS_ERR(our_chip->tclk1) ? clk_get_rate(our_chip->tclk1) : 0);
return 0; return 0;
} }
static void pwm_samsung_remove(struct platform_device *pdev) static void pwm_samsung_remove(struct platform_device *pdev)
{ {
struct samsung_pwm_chip *chip = platform_get_drvdata(pdev); struct samsung_pwm_chip *our_chip = platform_get_drvdata(pdev);
pwmchip_remove(&chip->chip); pwmchip_remove(&our_chip->chip);
clk_disable_unprepare(chip->base_clk); clk_disable_unprepare(our_chip->base_clk);
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment