mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
device: split fastboot_open from device_open
Create new function calling fastboot_open so that device_open doesn't have dependency on the fastboot_ops or udev. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
This commit is contained in:
@@ -55,12 +55,14 @@ static struct fastboot_ops fastboot_ops = {
|
||||
|
||||
static void msg_select_board(const void *param)
|
||||
{
|
||||
selected_device = device_open(param, username, &fastboot_ops);
|
||||
selected_device = device_open(param, username);
|
||||
if (!selected_device) {
|
||||
fprintf(stderr, "failed to open %s\n", (const char *)param);
|
||||
watch_quit();
|
||||
}
|
||||
|
||||
device_fastboot_open(selected_device, &fastboot_ops);
|
||||
|
||||
cdba_send(MSG_SELECT_BOARD);
|
||||
}
|
||||
|
||||
|
||||
23
device.c
23
device.c
@@ -95,8 +95,7 @@ static bool device_check_access(struct device *device,
|
||||
}
|
||||
|
||||
struct device *device_open(const char *board,
|
||||
const char *username,
|
||||
struct fastboot_ops *fastboot_ops)
|
||||
const char *username)
|
||||
{
|
||||
struct device *device;
|
||||
|
||||
@@ -136,8 +135,6 @@ found:
|
||||
if (device->usb_always_on)
|
||||
device_usb(device, true);
|
||||
|
||||
device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -275,18 +272,36 @@ int device_write(struct device *device, const void *buf, size_t len)
|
||||
return device_console(device, write, buf, len);
|
||||
}
|
||||
|
||||
void device_fastboot_open(struct device *device,
|
||||
struct fastboot_ops *fastboot_ops)
|
||||
{
|
||||
device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL);
|
||||
}
|
||||
|
||||
void device_fastboot_boot(struct device *device)
|
||||
{
|
||||
if (!device->fastboot) {
|
||||
fprintf(stderr, "fastboot not opened\n");
|
||||
return;
|
||||
}
|
||||
fastboot_boot(device->fastboot);
|
||||
}
|
||||
|
||||
void device_fastboot_continue(struct device *device)
|
||||
{
|
||||
if (!device->fastboot) {
|
||||
fprintf(stderr, "fastboot not opened\n");
|
||||
return;
|
||||
}
|
||||
fastboot_continue(device->fastboot);
|
||||
}
|
||||
|
||||
void device_fastboot_flash_reboot(struct device *device)
|
||||
{
|
||||
if (!device->fastboot) {
|
||||
fprintf(stderr, "fastboot not opened\n");
|
||||
return;
|
||||
}
|
||||
fastboot_flash(device->fastboot, "boot");
|
||||
fastboot_reboot(device->fastboot);
|
||||
}
|
||||
|
||||
5
device.h
5
device.h
@@ -72,8 +72,7 @@ struct device_user {
|
||||
void device_add(struct device *device);
|
||||
|
||||
struct device *device_open(const char *board,
|
||||
const char *username,
|
||||
struct fastboot_ops *fastboot_ops);
|
||||
const char *username);
|
||||
void device_close(struct device *dev);
|
||||
int device_power(struct device *device, bool on);
|
||||
|
||||
@@ -83,6 +82,8 @@ int device_write(struct device *device, const void *buf, size_t len);
|
||||
|
||||
void device_boot(struct device *device, const void *data, size_t len);
|
||||
|
||||
void device_fastboot_open(struct device *device,
|
||||
struct fastboot_ops *fastboot_ops);
|
||||
void device_fastboot_boot(struct device *device);
|
||||
void device_fastboot_flash_reboot(struct device *device);
|
||||
void device_send_break(struct device *device);
|
||||
|
||||
Reference in New Issue
Block a user