mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-25 03:55:09 +08:00
Input: ads7846 - add short-hand for spi->dev in probe() function
This will make the code a bit more terse. No functional change intended. Signed-off-by: Daniel Mack <daniel@zonque.org> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.kernel.org/r/20210907200726.2034962-2-daniel@zonque.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
daf87bffd0
commit
de609b56b8
@ -1216,19 +1216,20 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
{
|
{
|
||||||
const struct ads7846_platform_data *pdata;
|
const struct ads7846_platform_data *pdata;
|
||||||
struct ads7846 *ts;
|
struct ads7846 *ts;
|
||||||
|
struct device *dev = &spi->dev;
|
||||||
struct ads7846_packet *packet;
|
struct ads7846_packet *packet;
|
||||||
struct input_dev *input_dev;
|
struct input_dev *input_dev;
|
||||||
unsigned long irq_flags;
|
unsigned long irq_flags;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!spi->irq) {
|
if (!spi->irq) {
|
||||||
dev_dbg(&spi->dev, "no IRQ?\n");
|
dev_dbg(dev, "no IRQ?\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't exceed max specified sample rate */
|
/* don't exceed max specified sample rate */
|
||||||
if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
|
if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
|
||||||
dev_err(&spi->dev, "f(sample) %d KHz?\n",
|
dev_err(dev, "f(sample) %d KHz?\n",
|
||||||
(spi->max_speed_hz/SAMPLE_BITS)/1000);
|
(spi->max_speed_hz/SAMPLE_BITS)/1000);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -1262,9 +1263,9 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
mutex_init(&ts->lock);
|
mutex_init(&ts->lock);
|
||||||
init_waitqueue_head(&ts->wait);
|
init_waitqueue_head(&ts->wait);
|
||||||
|
|
||||||
pdata = dev_get_platdata(&spi->dev);
|
pdata = dev_get_platdata(dev);
|
||||||
if (!pdata) {
|
if (!pdata) {
|
||||||
pdata = ads7846_probe_dt(&spi->dev);
|
pdata = ads7846_probe_dt(dev);
|
||||||
if (IS_ERR(pdata)) {
|
if (IS_ERR(pdata)) {
|
||||||
err = PTR_ERR(pdata);
|
err = PTR_ERR(pdata);
|
||||||
goto err_free_mem;
|
goto err_free_mem;
|
||||||
@ -1306,12 +1307,12 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
|
|
||||||
ts->wait_for_sync = pdata->wait_for_sync ? : null_wait_for_sync;
|
ts->wait_for_sync = pdata->wait_for_sync ? : null_wait_for_sync;
|
||||||
|
|
||||||
snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&spi->dev));
|
snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
|
||||||
snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model);
|
snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model);
|
||||||
|
|
||||||
input_dev->name = ts->name;
|
input_dev->name = ts->name;
|
||||||
input_dev->phys = ts->phys;
|
input_dev->phys = ts->phys;
|
||||||
input_dev->dev.parent = &spi->dev;
|
input_dev->dev.parent = dev;
|
||||||
|
|
||||||
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
||||||
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
||||||
@ -1345,16 +1346,16 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
|
|
||||||
ads7846_setup_spi_msg(ts, pdata);
|
ads7846_setup_spi_msg(ts, pdata);
|
||||||
|
|
||||||
ts->reg = regulator_get(&spi->dev, "vcc");
|
ts->reg = regulator_get(dev, "vcc");
|
||||||
if (IS_ERR(ts->reg)) {
|
if (IS_ERR(ts->reg)) {
|
||||||
err = PTR_ERR(ts->reg);
|
err = PTR_ERR(ts->reg);
|
||||||
dev_err(&spi->dev, "unable to get regulator: %d\n", err);
|
dev_err(dev, "unable to get regulator: %d\n", err);
|
||||||
goto err_free_gpio;
|
goto err_free_gpio;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = regulator_enable(ts->reg);
|
err = regulator_enable(ts->reg);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
|
dev_err(dev, "unable to enable regulator: %d\n", err);
|
||||||
goto err_put_regulator;
|
goto err_put_regulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1362,18 +1363,18 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
irq_flags |= IRQF_ONESHOT;
|
irq_flags |= IRQF_ONESHOT;
|
||||||
|
|
||||||
err = request_threaded_irq(spi->irq, ads7846_hard_irq, ads7846_irq,
|
err = request_threaded_irq(spi->irq, ads7846_hard_irq, ads7846_irq,
|
||||||
irq_flags, spi->dev.driver->name, ts);
|
irq_flags, dev->driver->name, ts);
|
||||||
if (err && !pdata->irq_flags) {
|
if (err && !pdata->irq_flags) {
|
||||||
dev_info(&spi->dev,
|
dev_info(dev,
|
||||||
"trying pin change workaround on irq %d\n", spi->irq);
|
"trying pin change workaround on irq %d\n", spi->irq);
|
||||||
irq_flags |= IRQF_TRIGGER_RISING;
|
irq_flags |= IRQF_TRIGGER_RISING;
|
||||||
err = request_threaded_irq(spi->irq,
|
err = request_threaded_irq(spi->irq,
|
||||||
ads7846_hard_irq, ads7846_irq,
|
ads7846_hard_irq, ads7846_irq,
|
||||||
irq_flags, spi->dev.driver->name, ts);
|
irq_flags, dev->driver->name, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
|
dev_dbg(dev, "irq %d busy?\n", spi->irq);
|
||||||
goto err_disable_regulator;
|
goto err_disable_regulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,18 +1382,18 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_free_irq;
|
goto err_free_irq;
|
||||||
|
|
||||||
dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
|
dev_info(dev, "touchscreen, irq %d\n", spi->irq);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a first sample, leaving nPENIRQ active and vREF off; avoid
|
* Take a first sample, leaving nPENIRQ active and vREF off; avoid
|
||||||
* the touchscreen, in case it's not connected.
|
* the touchscreen, in case it's not connected.
|
||||||
*/
|
*/
|
||||||
if (ts->model == 7845)
|
if (ts->model == 7845)
|
||||||
ads7845_read12_ser(&spi->dev, PWRDOWN);
|
ads7845_read12_ser(dev, PWRDOWN);
|
||||||
else
|
else
|
||||||
(void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux));
|
(void) ads7846_read12_ser(dev, READ_12BIT_SER(vaux));
|
||||||
|
|
||||||
err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group);
|
err = sysfs_create_group(&dev->kobj, &ads784x_attr_group);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_remove_hwmon;
|
goto err_remove_hwmon;
|
||||||
|
|
||||||
@ -1400,19 +1401,19 @@ static int ads7846_probe(struct spi_device *spi)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_remove_attr_group;
|
goto err_remove_attr_group;
|
||||||
|
|
||||||
device_init_wakeup(&spi->dev, pdata->wakeup);
|
device_init_wakeup(dev, pdata->wakeup);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If device does not carry platform data we must have allocated it
|
* If device does not carry platform data we must have allocated it
|
||||||
* when parsing DT data.
|
* when parsing DT data.
|
||||||
*/
|
*/
|
||||||
if (!dev_get_platdata(&spi->dev))
|
if (!dev_get_platdata(dev))
|
||||||
devm_kfree(&spi->dev, (void *)pdata);
|
devm_kfree(dev, (void *)pdata);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_remove_attr_group:
|
err_remove_attr_group:
|
||||||
sysfs_remove_group(&spi->dev.kobj, &ads784x_attr_group);
|
sysfs_remove_group(&dev->kobj, &ads784x_attr_group);
|
||||||
err_remove_hwmon:
|
err_remove_hwmon:
|
||||||
ads784x_hwmon_unregister(spi, ts);
|
ads784x_hwmon_unregister(spi, ts);
|
||||||
err_free_irq:
|
err_free_irq:
|
||||||
|
Loading…
Reference in New Issue
Block a user