Commit 6797e19d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: usbtouchscreen - use driver core to instantiate device attributes

Instead of manually creating driver-specific device attributes
set struct usb_driver->dev_groups pointer to have the driver core
do it.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240712051851.3463657-1-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent d13df21d
...@@ -240,6 +240,7 @@ static const struct usb_device_id usbtouch_devices[] = { ...@@ -240,6 +240,7 @@ static const struct usb_device_id usbtouch_devices[] = {
{} {}
}; };
static struct usbtouch_device_info usbtouch_dev_info[];
/***************************************************************************** /*****************************************************************************
* e2i Part * e2i Part
...@@ -466,7 +467,19 @@ static struct attribute *mtouch_attrs[] = { ...@@ -466,7 +467,19 @@ static struct attribute *mtouch_attrs[] = {
NULL NULL
}; };
static bool mtouch_group_visible(struct kobject *kobj)
{
struct device *dev = kobj_to_dev(kobj);
struct usb_interface *intf = to_usb_interface(dev);
struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
return usbtouch->type == &usbtouch_dev_info[DEVTYPE_3M];
}
DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(mtouch);
static const struct attribute_group mtouch_attr_group = { static const struct attribute_group mtouch_attr_group = {
.is_visible = SYSFS_GROUP_VISIBLE(mtouch),
.attrs = mtouch_attrs, .attrs = mtouch_attrs,
}; };
...@@ -506,21 +519,12 @@ static int mtouch_get_fw_revision(struct usbtouch_usb *usbtouch) ...@@ -506,21 +519,12 @@ static int mtouch_get_fw_revision(struct usbtouch_usb *usbtouch)
static int mtouch_alloc(struct usbtouch_usb *usbtouch) static int mtouch_alloc(struct usbtouch_usb *usbtouch)
{ {
struct mtouch_priv *priv; struct mtouch_priv *priv;
int ret;
priv = kmalloc(sizeof(*priv), GFP_KERNEL); priv = kmalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
usbtouch->priv = priv; usbtouch->priv = priv;
ret = sysfs_create_group(&usbtouch->interface->dev.kobj,
&mtouch_attr_group);
if (ret) {
kfree(usbtouch->priv);
usbtouch->priv = NULL;
return ret;
}
return 0; return 0;
} }
...@@ -571,7 +575,6 @@ static void mtouch_exit(struct usbtouch_usb *usbtouch) ...@@ -571,7 +575,6 @@ static void mtouch_exit(struct usbtouch_usb *usbtouch)
{ {
struct mtouch_priv *priv = usbtouch->priv; struct mtouch_priv *priv = usbtouch->priv;
sysfs_remove_group(&usbtouch->interface->dev.kobj, &mtouch_attr_group);
kfree(priv); kfree(priv);
} }
#endif #endif
...@@ -1842,6 +1845,13 @@ static void usbtouch_disconnect(struct usb_interface *intf) ...@@ -1842,6 +1845,13 @@ static void usbtouch_disconnect(struct usb_interface *intf)
kfree(usbtouch); kfree(usbtouch);
} }
static const struct attribute_group *usbtouch_groups[] = {
#ifdef CONFIG_TOUCHSCREEN_USB_3M
&mtouch_attr_group,
#endif
NULL
};
MODULE_DEVICE_TABLE(usb, usbtouch_devices); MODULE_DEVICE_TABLE(usb, usbtouch_devices);
static struct usb_driver usbtouch_driver = { static struct usb_driver usbtouch_driver = {
...@@ -1852,6 +1862,7 @@ static struct usb_driver usbtouch_driver = { ...@@ -1852,6 +1862,7 @@ static struct usb_driver usbtouch_driver = {
.resume = usbtouch_resume, .resume = usbtouch_resume,
.reset_resume = usbtouch_reset_resume, .reset_resume = usbtouch_reset_resume,
.id_table = usbtouch_devices, .id_table = usbtouch_devices,
.dev_groups = usbtouch_groups,
.supports_autosuspend = 1, .supports_autosuspend = 1,
}; };
......
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