1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __FIRMWARE_UPLOAD_H 3 #define __FIRMWARE_UPLOAD_H 4 5 #include <linux/device.h> 6 7 /** 8 * enum fw_upload_prog - firmware upload progress codes 9 * @FW_UPLOAD_PROG_IDLE: there is no firmware upload in progress 10 * @FW_UPLOAD_PROG_RECEIVING: worker thread is receiving firmware data 11 * @FW_UPLOAD_PROG_PREPARING: target device is preparing for firmware upload 12 * @FW_UPLOAD_PROG_TRANSFERRING: data is being copied to the device 13 * @FW_UPLOAD_PROG_PROGRAMMING: device is performing the firmware update 14 * @FW_UPLOAD_PROG_MAX: Maximum progress code marker 15 */ 16 enum fw_upload_prog { 17 FW_UPLOAD_PROG_IDLE, 18 FW_UPLOAD_PROG_RECEIVING, 19 FW_UPLOAD_PROG_PREPARING, 20 FW_UPLOAD_PROG_TRANSFERRING, 21 FW_UPLOAD_PROG_PROGRAMMING, 22 FW_UPLOAD_PROG_MAX 23 }; 24 25 struct fw_upload_priv { 26 struct fw_upload *fw_upload; 27 struct module *module; 28 const char *name; 29 const struct fw_upload_ops *ops; 30 struct mutex lock; /* protect data structure contents */ 31 struct work_struct work; 32 const u8 *data; /* pointer to update data */ 33 u32 remaining_size; /* size remaining to transfer */ 34 enum fw_upload_prog progress; 35 enum fw_upload_prog err_progress; /* progress at time of failure */ 36 enum fw_upload_err err_code; /* security manager error code */ 37 }; 38 39 #ifdef CONFIG_FW_UPLOAD 40 extern struct device_attribute dev_attr_status; 41 extern struct device_attribute dev_attr_error; 42 extern struct device_attribute dev_attr_cancel; 43 extern struct device_attribute dev_attr_remaining_size; 44 45 int fw_upload_start(struct fw_sysfs *fw_sysfs); 46 umode_t fw_upload_is_visible(struct kobject *kobj, struct attribute *attr, int n); 47 #else 48 static inline int fw_upload_start(struct fw_sysfs *fw_sysfs) 49 { 50 return 0; 51 } 52 #endif 53 54 #endif /* __FIRMWARE_UPLOAD_H */ 55