forked from drath/libratbag
Drop device handle from the button, the profile has it
...and buttons must be part of a profile. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -322,8 +322,8 @@ etekcity_button_to_index(unsigned button)
|
||||
static void
|
||||
etekcity_read_button(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_device *device = button->device;
|
||||
struct ratbag_profile *profile = button->profile;
|
||||
struct ratbag_device *device = profile->device;
|
||||
struct etekcity_data *drv_data = ratbag_get_drv_data(device);
|
||||
uint8_t data;
|
||||
unsigned index = etekcity_button_to_index(button->index);
|
||||
@@ -339,8 +339,8 @@ etekcity_read_button(struct ratbag_button *button)
|
||||
static int
|
||||
etekcity_write_button(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_device *device = button->device;
|
||||
struct ratbag_profile *profile = button->profile;
|
||||
struct ratbag_device *device = profile->device;
|
||||
struct etekcity_data *drv_data = ratbag_get_drv_data(device);
|
||||
uint8_t *data;
|
||||
unsigned index = etekcity_button_to_index(button->index);
|
||||
|
||||
@@ -73,7 +73,7 @@ hidpp20drv_raw_to_action(enum ratbag_button_type button_type)
|
||||
static void
|
||||
hidpp20drv_read_button(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_device *device = button->device;
|
||||
struct ratbag_device *device = button->profile->device;
|
||||
struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
|
||||
struct hidpp20_control_id *control;
|
||||
uint16_t mapping;
|
||||
@@ -99,7 +99,7 @@ hidpp20drv_read_button(struct ratbag_button *button)
|
||||
static int
|
||||
hidpp20drv_write_button(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_device *device = button->device;
|
||||
struct ratbag_device *device = button->profile->device;
|
||||
struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
|
||||
struct hidpp20_control_id *control;
|
||||
uint16_t mapping;
|
||||
|
||||
@@ -188,7 +188,6 @@ struct ratbag_profile {
|
||||
struct ratbag_button {
|
||||
int refcount;
|
||||
struct list link;
|
||||
struct ratbag_device *device;
|
||||
struct ratbag_profile *profile;
|
||||
unsigned index;
|
||||
enum ratbag_button_type type;
|
||||
|
||||
@@ -639,7 +639,6 @@ ratbag_create_button(struct ratbag_device *device, struct ratbag_profile *profil
|
||||
return NULL;
|
||||
|
||||
button->refcount = 1;
|
||||
button->device = device;
|
||||
button->profile = profile;
|
||||
button->index = index;
|
||||
|
||||
@@ -681,11 +680,11 @@ ratbag_button_set_type(struct ratbag_button *button, enum ratbag_button_type typ
|
||||
enum ratbag_button_type orig_type = button->type;
|
||||
int rc;
|
||||
|
||||
if (!button->device->driver->write_button)
|
||||
if (!button->profile->device->driver->write_button)
|
||||
return -ENOTSUP;
|
||||
|
||||
button->type = type;
|
||||
rc = button->device->driver->write_button(button);
|
||||
rc = button->profile->device->driver->write_button(button);
|
||||
if (rc)
|
||||
button->type = orig_type;
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user