From 9f518bed0ce4eb4772a7bab2df3020607a85d772 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 20 Aug 2015 14:58:31 +1000 Subject: [PATCH] Drop device/profile arguments from driver read_button/write_button The button struct contains references to both. Signed-off-by: Peter Hutterer --- src/etekcity.c | 10 ++++++---- src/libratbag-private.h | 6 ++---- src/libratbag.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/etekcity.c b/src/etekcity.c index d44a78a2..2d845a70 100644 --- a/src/etekcity.c +++ b/src/etekcity.c @@ -320,9 +320,10 @@ etekcity_button_to_index(unsigned button) } static void -etekcity_read_button(struct ratbag_device *device, struct ratbag_profile *profile, - struct ratbag_button *button) +etekcity_read_button(struct ratbag_button *button) { + struct ratbag_device *device = button->device; + struct ratbag_profile *profile = button->profile; struct etekcity_data *drv_data = ratbag_get_drv_data(device); uint8_t data; unsigned index = etekcity_button_to_index(button->index); @@ -336,9 +337,10 @@ etekcity_read_button(struct ratbag_device *device, struct ratbag_profile *profil } static int -etekcity_write_button(struct ratbag_device *device, struct ratbag_profile *profile, - struct ratbag_button *button) +etekcity_write_button(struct ratbag_button *button) { + struct ratbag_device *device = button->device; + struct ratbag_profile *profile = button->profile; struct etekcity_data *drv_data = ratbag_get_drv_data(device); uint8_t *data; unsigned index = etekcity_button_to_index(button->index); diff --git a/src/libratbag-private.h b/src/libratbag-private.h index a318b322..21a0ab25 100644 --- a/src/libratbag-private.h +++ b/src/libratbag-private.h @@ -150,8 +150,7 @@ struct ratbag_driver { * actually read the profile from the device. The caller * should make sure that the profile is up to date. */ - void (*read_button)(struct ratbag_device *device, struct ratbag_profile *profile, - struct ratbag_button *button); + void (*read_button)(struct ratbag_button *button); /** For the given button, store in the profile or in the device * the given struct ratbag_button. @@ -164,8 +163,7 @@ struct ratbag_driver { * should later on write the profile in one call to * .write_profile(). */ - int (*write_button)(struct ratbag_device *device, struct ratbag_profile *profile, - struct ratbag_button *button); + int (*write_button)(struct ratbag_button *button); /* private */ struct list link; diff --git a/src/libratbag.c b/src/libratbag.c index e56cb18d..5f91bbb0 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -581,7 +581,7 @@ ratbag_create_button(struct ratbag_device *device, struct ratbag_profile *profil list_insert(&profile->buttons, &button->link); if (device->driver->read_button) - device->driver->read_button(device, profile, button); + device->driver->read_button(button); return button; } @@ -595,7 +595,7 @@ ratbag_profile_get_button_by_index(struct ratbag_profile *profile, list_for_each(button, &profile->buttons, link) { if (button->index == index) { if (profile->device->driver->read_button) - profile->device->driver->read_button(profile->device, profile, button); + profile->device->driver->read_button(button); return ratbag_button_ref(button); } } @@ -619,7 +619,7 @@ ratbag_button_set_type(struct ratbag_button *button, enum ratbag_button_type typ return -ENOTSUP; button->type = type; - rc = button->device->driver->write_button(button->device, button->profile, button); + rc = button->device->driver->write_button(button); if (rc) button->type = orig_type; return rc;