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

Input: iqs5xx - make reset GPIO optional

The device's hardware reset pin is only required if the platform
must be able to update the device's firmware.

As such, demote the reset GPIO to optional in support of devices
that ship with pre-programmed firmware and don't route the reset
pin back to the SoC.

In that case, the 'fw_file' attribute is hidden because there is
no way to open the bootloader. The logic is extended to the case
in which the device does not advertise bootloader support in the
first place.

Last but not least, remove the hardware reset performed at probe
because there is no reason to reset the device manually. A power
on reset function already ensures a clean reset at start-up.

Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Link: https://lore.kernel.org/r/20210323021006.367-1-jeff@labundy.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jeff LaBundy and committed by
Dmitry Torokhov
9d41359c f1d2809d

+17 -8
+17 -8
drivers/input/touchscreen/iqs5xx.c
··· 835 835 int error, error_init = 0; 836 836 u8 *pmap; 837 837 838 - if (iqs5xx->dev_id_info.bl_status == IQS5XX_BL_STATUS_NONE) 839 - return -EPERM; 840 - 841 838 pmap = kzalloc(IQS5XX_PMAP_LEN, GFP_KERNEL); 842 839 if (!pmap) 843 840 return -ENOMEM; ··· 960 963 NULL, 961 964 }; 962 965 966 + static umode_t iqs5xx_attr_is_visible(struct kobject *kobj, 967 + struct attribute *attr, int i) 968 + { 969 + struct device *dev = kobj_to_dev(kobj); 970 + struct iqs5xx_private *iqs5xx = dev_get_drvdata(dev); 971 + 972 + if (attr == &dev_attr_fw_file.attr && 973 + (iqs5xx->dev_id_info.bl_status == IQS5XX_BL_STATUS_NONE || 974 + !iqs5xx->reset_gpio)) 975 + return 0; 976 + 977 + return attr->mode; 978 + } 979 + 963 980 static const struct attribute_group iqs5xx_attr_group = { 981 + .is_visible = iqs5xx_attr_is_visible, 964 982 .attrs = iqs5xx_attrs, 965 983 }; 966 984 ··· 1032 1020 i2c_set_clientdata(client, iqs5xx); 1033 1021 iqs5xx->client = client; 1034 1022 1035 - iqs5xx->reset_gpio = devm_gpiod_get(&client->dev, 1036 - "reset", GPIOD_OUT_LOW); 1023 + iqs5xx->reset_gpio = devm_gpiod_get_optional(&client->dev, 1024 + "reset", GPIOD_OUT_LOW); 1037 1025 if (IS_ERR(iqs5xx->reset_gpio)) { 1038 1026 error = PTR_ERR(iqs5xx->reset_gpio); 1039 1027 dev_err(&client->dev, "Failed to request GPIO: %d\n", error); ··· 1041 1029 } 1042 1030 1043 1031 mutex_init(&iqs5xx->lock); 1044 - 1045 - iqs5xx_reset(client); 1046 - usleep_range(10000, 10100); 1047 1032 1048 1033 error = iqs5xx_dev_init(client); 1049 1034 if (error)