mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
device: Invoke device->close on exit
Allow the control device to implement things such as flushing the command buffer as part of the close operation. This used to be done to ensure that any lingering power/usb off requests really where sent to the device as we closed the control tty. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
@@ -293,8 +293,10 @@ void *cdb_assist_open(struct device *dev)
|
||||
return cdb;
|
||||
}
|
||||
|
||||
void cdb_assist_close(struct cdb_assist *cdb)
|
||||
void cdb_assist_close(struct device *dev)
|
||||
{
|
||||
struct cdb_assist *cdb = dev->cdb;
|
||||
|
||||
tcflush(cdb->control_tty, TCIFLUSH);
|
||||
|
||||
close(cdb->control_tty);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
struct cdb_assist;
|
||||
|
||||
void *cdb_assist_open(struct device *dev);
|
||||
void cdb_assist_close(struct cdb_assist *cdb);
|
||||
void cdb_assist_close(struct device *dev);
|
||||
|
||||
int cdb_assist_power(struct device *dev, bool on);
|
||||
void cdb_assist_usb(struct device *dev, bool on);
|
||||
|
||||
3
device.c
3
device.c
@@ -311,4 +311,7 @@ void device_close(struct device *dev)
|
||||
{
|
||||
device_usb(dev, false);
|
||||
device_power(dev, false);
|
||||
|
||||
if (dev->close)
|
||||
dev->close(dev);
|
||||
}
|
||||
|
||||
1
device.h
1
device.h
@@ -26,6 +26,7 @@ struct device {
|
||||
void (*boot)(struct device *);
|
||||
|
||||
void *(*open)(struct device *dev);
|
||||
void (*close)(struct device *dev);
|
||||
int (*power)(struct device *dev, bool on);
|
||||
void (*usb)(struct device *dev, bool on);
|
||||
void (*print_status)(struct device *dev);
|
||||
|
||||
@@ -99,6 +99,7 @@ static void parse_board(struct device_parser *dp)
|
||||
dev->control_dev = strdup(value);
|
||||
|
||||
dev->open = cdb_assist_open;
|
||||
dev->close = cdb_assist_close;
|
||||
dev->power = cdb_assist_power;
|
||||
dev->print_status = cdb_assist_print_status;
|
||||
dev->usb = cdb_assist_usb;
|
||||
|
||||
Reference in New Issue
Block a user