From 7da4bd7e1e32752ac4b39b0418d793085fc88f26 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 20 Oct 2015 21:43:59 -0400 Subject: [PATCH] hidpp10: rename hidpp10_device_new_from_idx into hidpp10_device_new There is only one constructor left. Get rid of the static hidpp10_device_new() that is not adding much. Signed-off-by: Benjamin Tissoires --- src/driver-hidpp10.c | 2 +- src/hidpp10.c | 24 ++++-------------------- src/hidpp10.h | 3 +-- tools/hidpp10-dump-page.c | 2 +- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 954cc631..379dbd55 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -234,7 +234,7 @@ hidpp10drv_probe(struct ratbag_device *device) * so even for unifying receiver devices we can just 0x00 as device * index. */ - dev = hidpp10_device_new_from_idx(&base, WIRED_DEVICE_IDX); + dev = hidpp10_device_new(&base, WIRED_DEVICE_IDX); if (!dev) { log_error(device->ratbag, diff --git a/src/hidpp10.c b/src/hidpp10.c index ef6efcce..87dd7ca5 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -1222,32 +1222,16 @@ hidpp10_get_device_info(struct hidpp10_device *dev) return 0; } -static struct hidpp10_device* -hidpp10_device_new(const struct hidpp_device *base, - int index) +struct hidpp10_device* +hidpp10_device_new(const struct hidpp_device *base, int idx) { struct hidpp10_device *dev; dev = zalloc(sizeof(*dev)); - if (!dev) - return NULL; - - dev->index = index; - dev->base = *base; - - return dev; -} - -struct hidpp10_device* -hidpp10_device_new_from_idx(const struct hidpp_device *base, int idx) -{ - struct hidpp10_device *dev; - - dev = hidpp10_device_new(base, idx); - if (!dev) - return NULL; dev->index = idx; + dev->base = *base; + if (hidpp10_get_device_info(dev) != 0) { hidpp10_device_destroy(dev); dev = NULL; diff --git a/src/hidpp10.h b/src/hidpp10.h index 332162a9..0b0ab099 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -46,8 +46,7 @@ struct hidpp10_device { }; struct hidpp10_device* -hidpp10_device_new_from_idx(const struct hidpp_device *base, - int idx); +hidpp10_device_new(const struct hidpp_device *base, int idx); void hidpp10_device_destroy(struct hidpp10_device *dev); diff --git a/tools/hidpp10-dump-page.c b/tools/hidpp10-dump-page.c index 13143e9e..a78242ac 100644 --- a/tools/hidpp10-dump-page.c +++ b/tools/hidpp10-dump-page.c @@ -98,7 +98,7 @@ main(int argc, char **argv) error(1, errno, "Failed to open path %s", path); hidpp_device_init(&base, fd); - dev = hidpp10_device_new_from_idx(&base, WIRED_DEVICE_IDX); + dev = hidpp10_device_new(&base, WIRED_DEVICE_IDX); if (argc == 2) rc = dump_all_pages(dev);