Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: max8997 - convert to modern way to get a reference to a PWM

pwm_request() isn't recommended to be used any more because it relies on
global IDs for the PWM which comes with different difficulties.

The new way to do things is to find the right PWM using a reference from
the platform device. (This can be created either using a device-tree
or a platform lookup table, see e.g. commit 5a4412d4a82f ("ARM: pxa:
tavorevb: Use PWM lookup table") how to do this.)

There are no in-tree users, so there are no other code locations that need
adaption.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20221117073543.3790449-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Uwe Kleine-König and committed by
Dmitry Torokhov
b76f64ca a85fbd64

+3 -7
+3 -4
drivers/input/misc/max8997_haptic.c
··· 278 278 break; 279 279 280 280 case MAX8997_EXTERNAL_MODE: 281 - chip->pwm = pwm_request(haptic_pdata->pwm_channel_id, 282 - "max8997-haptic"); 281 + chip->pwm = pwm_get(&pdev->dev, NULL); 283 282 if (IS_ERR(chip->pwm)) { 284 283 error = PTR_ERR(chip->pwm); 285 284 dev_err(&pdev->dev, ··· 343 344 regulator_put(chip->regulator); 344 345 err_free_pwm: 345 346 if (chip->mode == MAX8997_EXTERNAL_MODE) 346 - pwm_free(chip->pwm); 347 + pwm_put(chip->pwm); 347 348 err_free_mem: 348 349 input_free_device(input_dev); 349 350 kfree(chip); ··· 359 360 regulator_put(chip->regulator); 360 361 361 362 if (chip->mode == MAX8997_EXTERNAL_MODE) 362 - pwm_free(chip->pwm); 363 + pwm_put(chip->pwm); 363 364 364 365 kfree(chip); 365 366
-3
include/linux/mfd/max8997.h
··· 110 110 111 111 /** 112 112 * max8997_haptic_platform_data 113 - * @pwm_channel_id: channel number of PWM device 114 - * valid for MAX8997_EXTERNAL_MODE 115 113 * @pwm_period: period in nano second for PWM device 116 114 * valid for MAX8997_EXTERNAL_MODE 117 115 * @type: motor type ··· 126 128 * [0 - 255]: available period 127 129 */ 128 130 struct max8997_haptic_platform_data { 129 - unsigned int pwm_channel_id; 130 131 unsigned int pwm_period; 131 132 132 133 enum max8997_haptic_motor_type type;