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 <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires
2015-10-20 21:43:59 -04:00
parent 40fe1b0eac
commit 7da4bd7e1e
4 changed files with 7 additions and 24 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);