* [PATCH 2/5] HID: magicmouse: report battery capacity over bluetooth
2021-05-11 18:20 [PATCH 1/5] HID: magicmouse: register power supply José Expósito
@ 2021-05-11 18:20 ` José Expósito
2021-05-11 18:20 ` [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: José Expósito @ 2021-05-11 18:20 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, linux-input, linux-kernel, José Expósito
Report the battery capacity percentage for the Apple Magic Mouse 2
and the Apple Magic Trackpad 2 when they are connected over bluetooth.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-magicmouse.c | 54 ++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 0f766bce4537..d4a58dd6d2b8 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -57,6 +57,8 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
#define MOUSE_REPORT_ID 0x29
#define MOUSE2_REPORT_ID 0x12
#define DOUBLE_REPORT_ID 0xf7
+#define BT_BATTERY_REPORT_ID 0x90
+
/* These definitions are not precise, but they're close enough. (Bits
* 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem
* to be some kind of bit mask -- 0x20 may be a near-field reading,
@@ -139,12 +141,14 @@ struct magicmouse_sc {
struct {
struct power_supply *ps;
struct power_supply_desc ps_desc;
+ int capacity;
} battery;
};
static enum power_supply_property magicmouse_ps_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_SCOPE,
+ POWER_SUPPLY_PROP_CAPACITY,
};
static bool magicmouse_can_report_battery(struct magicmouse_sc *msc)
@@ -153,6 +157,49 @@ static bool magicmouse_can_report_battery(struct magicmouse_sc *msc)
(msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2);
}
+static bool magicmouse_can_report_battery_vendor(struct magicmouse_sc *msc,
+ unsigned short vendor)
+{
+ return magicmouse_can_report_battery(msc) &&
+ (msc->input->id.vendor == vendor);
+}
+
+static int magicmouse_battery_bt_get_capacity(struct magicmouse_sc *msc)
+{
+ struct hid_report_enum report_enum;
+ struct hid_report *report;
+ int ret;
+
+ if (!magicmouse_can_report_battery_vendor(msc, BT_VENDOR_ID_APPLE))
+ return -EINVAL;
+
+ report_enum = msc->hdev->report_enum[HID_INPUT_REPORT];
+ report = report_enum.report_id_hash[BT_BATTERY_REPORT_ID];
+
+ if (!report || report->maxfield < 1) {
+ hid_err(msc->hdev, "failed to retrieve report with ID %d\n",
+ BT_BATTERY_REPORT_ID);
+ return -EINVAL;
+ }
+
+ hid_hw_request(msc->hdev, report, HID_REQ_GET_REPORT);
+
+ if (!report || report->maxfield < 2) {
+ hid_err(msc->hdev, "invalid report->maxfield: %d\n",
+ report->maxfield);
+ return -EINVAL;
+ }
+
+ ret = report->field[0]->value[0];
+ if (ret < 0) {
+ hid_err(msc->hdev, "invalid report status %d\n", ret);
+ return ret;
+ }
+
+ msc->battery.capacity = report->field[1]->value[0];
+ return 0;
+}
+
static int magicmouse_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -170,6 +217,12 @@ static int magicmouse_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_SCOPE:
val->intval = POWER_SUPPLY_SCOPE_DEVICE;
break;
+ case POWER_SUPPLY_PROP_CAPACITY:
+ if (msc->input->id.vendor == BT_VENDOR_ID_APPLE)
+ magicmouse_battery_bt_get_capacity(msc);
+
+ val->intval = msc->battery.capacity;
+ break;
default:
ret = -EINVAL;
break;
@@ -188,6 +241,7 @@ static int magicmouse_battery_probe(struct hid_device *hdev)
if (!magicmouse_can_report_battery(msc))
return 0;
+ msc->battery.capacity = 100;
msc->battery.ps_desc.type = POWER_SUPPLY_TYPE_BATTERY;
msc->battery.ps_desc.properties = magicmouse_ps_props;
msc->battery.ps_desc.num_properties = ARRAY_SIZE(magicmouse_ps_props);
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-11 18:20 [PATCH 1/5] HID: magicmouse: register power supply José Expósito
2021-05-11 18:20 ` [PATCH 2/5] HID: magicmouse: report battery capacity over bluetooth José Expósito
@ 2021-05-11 18:20 ` José Expósito
2021-05-12 9:39 ` kernel test robot
2021-05-12 11:28 ` kernel test robot
2021-05-11 18:20 ` [PATCH 4/5] HID: magicmouse: Magic Mouse " José Expósito
2021-05-11 18:20 ` [PATCH 5/5] HID: magicmouse: report battery status José Expósito
3 siblings, 2 replies; 10+ messages in thread
From: José Expósito @ 2021-05-11 18:20 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, linux-input, linux-kernel, José Expósito
Report the battery capacity percentage for the Apple Magic Trackpad 2
when it is connected over USB.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-magicmouse.c | 136 +++++++++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index d4a58dd6d2b8..ea8a85767c39 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -16,6 +16,7 @@
#include <linux/input/mt.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/usb.h>
#include <linux/workqueue.h>
#include "hid-ids.h"
@@ -58,6 +59,7 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
#define MOUSE2_REPORT_ID 0x12
#define DOUBLE_REPORT_ID 0xf7
#define BT_BATTERY_REPORT_ID 0x90
+#define USB_BATTERY_EP_ADDR 0x81
/* These definitions are not precise, but they're close enough. (Bits
* 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem
@@ -142,6 +144,10 @@ struct magicmouse_sc {
struct power_supply *ps;
struct power_supply_desc ps_desc;
int capacity;
+ struct urb *urb;
+ u8 *urb_buf;
+ int urb_buf_size;
+ dma_addr_t urb_buf_dma;
} battery;
};
@@ -231,6 +237,112 @@ static int magicmouse_battery_get_property(struct power_supply *psy,
return ret;
}
+static void magicmouse_battery_usb_urb_complete(struct urb *urb)
+{
+ struct magicmouse_sc *msc = urb->context;
+ int ret;
+
+ switch (urb->status) {
+ case 0:
+ msc->battery.capacity = msc->battery.urb_buf[2];
+ break;
+ case -EOVERFLOW:
+ hid_err(msc->hdev, "URB overflow\n");
+ fallthrough;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ return;
+ default:
+ break;
+ }
+
+ ret = usb_submit_urb(msc->battery.urb, GFP_ATOMIC);
+ if (ret)
+ hid_err(msc->hdev, "unable to submit URB, %d\n", ret);
+}
+
+static int magicmouse_battery_usb_probe(struct magicmouse_sc *msc)
+{
+ struct usb_interface *iface = to_usb_interface(msc->hdev->dev.parent);
+ struct usb_device *usbdev = interface_to_usbdev(iface);
+ struct usb_host_endpoint *endpoint = NULL;
+ u8 ep_address;
+ unsigned int pipe = 0;
+ int i, ret;
+
+ if (!magicmouse_can_report_battery_vendor(msc, USB_VENDOR_ID_APPLE))
+ return -EINVAL;
+
+ for (i = 0; i < sizeof(usbdev->ep_in); i++) {
+ endpoint = usbdev->ep_in[i];
+ if (endpoint) {
+ ep_address = endpoint->desc.bEndpointAddress;
+ if (ep_address == USB_BATTERY_EP_ADDR)
+ break;
+ }
+ }
+
+ if (!endpoint) {
+ hid_err(msc->hdev, "endpoint with address %d not found\n",
+ USB_BATTERY_EP_ADDR);
+ ret = -EIO;
+ goto exit;
+ }
+
+ msc->battery.urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (!msc->battery.urb) {
+ hid_err(msc->hdev, "unable to alloc URB, ENOMEM\n");
+ ret = -ENOMEM;
+ goto exit;
+ }
+
+ pipe = usb_rcvintpipe(usbdev, endpoint->desc.bEndpointAddress);
+ if (pipe == 0) {
+ hid_err(msc->hdev, "unable to create USB rcvintpipe\n");
+ ret = -EIO;
+ goto err_free_urb;
+ }
+
+ msc->battery.urb_buf_size = endpoint->desc.wMaxPacketSize;
+ msc->battery.urb_buf_dma = msc->battery.urb->transfer_dma;
+ msc->battery.urb_buf = usb_alloc_coherent(usbdev,
+ msc->battery.urb_buf_size, GFP_ATOMIC,
+ &msc->battery.urb_buf_dma);
+ if (!msc->battery.urb_buf) {
+ hid_err(msc->hdev, "unable to alloc URB buffer, ENOMEM\n");
+ ret = -ENOMEM;
+ goto err_free_urb;
+ }
+
+ usb_fill_int_urb(msc->battery.urb, usbdev, pipe, msc->battery.urb_buf,
+ msc->battery.urb_buf_size,
+ magicmouse_battery_usb_urb_complete, msc,
+ endpoint->desc.bInterval);
+
+ ret = usb_submit_urb(msc->battery.urb, GFP_ATOMIC);
+ if (ret) {
+ hid_err(msc->hdev, "unable to submit URB, %d\n", ret);
+ goto err_free_urb_buf;
+ }
+
+ return 0;
+
+err_free_urb_buf:
+ usb_free_coherent(usbdev, msc->battery.urb_buf_size,
+ msc->battery.urb_buf, msc->battery.urb_buf_dma);
+
+err_free_urb:
+ usb_free_urb(msc->battery.urb);
+
+exit:
+ msc->battery.urb = NULL;
+ msc->battery.urb_buf = NULL;
+ msc->battery.urb_buf_size = 0;
+
+ return ret;
+}
+
static int magicmouse_battery_probe(struct hid_device *hdev)
{
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
@@ -269,6 +381,12 @@ static int magicmouse_battery_probe(struct hid_device *hdev)
return ret;
}
+ if (msc->input->id.vendor == USB_VENDOR_ID_APPLE) {
+ ret = magicmouse_battery_usb_probe(msc);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
@@ -923,7 +1041,25 @@ static int magicmouse_probe(struct hid_device *hdev,
static void magicmouse_remove(struct hid_device *hdev)
{
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
+ struct usb_interface *iface;
+ struct usb_device *usbdev;
cancel_delayed_work_sync(&msc->work);
+
+ if (msc &&
+ magicmouse_can_report_battery_vendor(msc, USB_VENDOR_ID_APPLE) &&
+ msc->battery.urb && msc->battery.urb_buf) {
+ iface = to_usb_interface(hdev->dev.parent);
+ usbdev = interface_to_usbdev(iface);
+
+ usb_kill_urb(msc->battery.urb);
+
+ usb_free_coherent(usbdev, msc->battery.urb_buf_size,
+ msc->battery.urb_buf,
+ msc->battery.urb_buf_dma);
+
+ usb_free_urb(msc->battery.urb);
+ }
+
hid_hw_stop(hdev);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-11 18:20 ` [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
@ 2021-05-12 9:39 ` kernel test robot
2021-05-15 18:50 ` José Expósito
2021-05-12 11:28 ` kernel test robot
1 sibling, 1 reply; 10+ messages in thread
From: kernel test robot @ 2021-05-12 9:39 UTC (permalink / raw)
To: José Expósito, jikos
Cc: kbuild-all, benjamin.tissoires, linux-input, linux-kernel,
José Expósito
[-- Attachment #1: Type: text/plain, Size: 3060 bytes --]
Hi "José,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hid/for-next]
[also build test ERROR on v5.13-rc1 next-20210511]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: s390-randconfig-r002-20210512 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/701f395a5566b6d2fd3a78389983237668902998
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
git checkout 701f395a5566b6d2fd3a78389983237668902998
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=s390
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
cistpl.c:(.text+0x3a2): undefined reference to `ioremap'
s390-linux-ld: cistpl.c:(.text+0x3dc): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0x404): undefined reference to `iounmap'
s390-linux-ld: cistpl.c:(.text+0x416): undefined reference to `ioremap'
s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
cistpl.c:(.text+0xe16): undefined reference to `iounmap'
s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_remove':
hid-magicmouse.c:(.text+0xd2c): undefined reference to `usb_kill_urb'
>> s390-linux-ld: hid-magicmouse.c:(.text+0xd48): undefined reference to `usb_free_coherent'
>> s390-linux-ld: hid-magicmouse.c:(.text+0xd54): undefined reference to `usb_free_urb'
s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_battery_usb_urb_complete':
hid-magicmouse.c:(.text+0xe12): undefined reference to `usb_submit_urb'
s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_probe':
hid-magicmouse.c:(.text+0x1194): undefined reference to `usb_alloc_urb'
>> s390-linux-ld: hid-magicmouse.c:(.text+0x121a): undefined reference to `usb_alloc_coherent'
s390-linux-ld: hid-magicmouse.c:(.text+0x1422): undefined reference to `usb_free_coherent'
s390-linux-ld: hid-magicmouse.c:(.text+0x142e): undefined reference to `usb_free_urb'
>> s390-linux-ld: hid-magicmouse.c:(.text+0x1462): undefined reference to `usb_submit_urb'
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 12628 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-12 9:39 ` kernel test robot
@ 2021-05-15 18:50 ` José Expósito
2021-05-20 9:18 ` [kbuild-all] " Rong Chen
0 siblings, 1 reply; 10+ messages in thread
From: José Expósito @ 2021-05-15 18:50 UTC (permalink / raw)
To: jose.exposito89
Cc: jikos, kbuild-all, benjamin.tissoires, linux-input, linux-kernel
On Wed, May 12, 2021 at 05:39:31PM +0800, kernel test robot wrote:
> Hi "José,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on hid/for-next]
> [also build test ERROR on v5.13-rc1 next-20210511]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
> base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
> config: s390-randconfig-r002-20210512 (attached as .config)
> compiler: s390-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/0day-ci/linux/commit/701f395a5566b6d2fd3a78389983237668902998
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
> git checkout 701f395a5566b6d2fd3a78389983237668902998
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=s390
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
> cistpl.c:(.text+0x3a2): undefined reference to `ioremap'
> s390-linux-ld: cistpl.c:(.text+0x3dc): undefined reference to `iounmap'
> s390-linux-ld: cistpl.c:(.text+0x404): undefined reference to `iounmap'
> s390-linux-ld: cistpl.c:(.text+0x416): undefined reference to `ioremap'
> s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
> cistpl.c:(.text+0xe16): undefined reference to `iounmap'
> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_remove':
> hid-magicmouse.c:(.text+0xd2c): undefined reference to `usb_kill_urb'
> >> s390-linux-ld: hid-magicmouse.c:(.text+0xd48): undefined reference to `usb_free_coherent'
> >> s390-linux-ld: hid-magicmouse.c:(.text+0xd54): undefined reference to `usb_free_urb'
> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_battery_usb_urb_complete':
> hid-magicmouse.c:(.text+0xe12): undefined reference to `usb_submit_urb'
> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_probe':
> hid-magicmouse.c:(.text+0x1194): undefined reference to `usb_alloc_urb'
> >> s390-linux-ld: hid-magicmouse.c:(.text+0x121a): undefined reference to `usb_alloc_coherent'
> s390-linux-ld: hid-magicmouse.c:(.text+0x1422): undefined reference to `usb_free_coherent'
> s390-linux-ld: hid-magicmouse.c:(.text+0x142e): undefined reference to `usb_free_urb'
> >> s390-linux-ld: hid-magicmouse.c:(.text+0x1462): undefined reference to `usb_submit_urb'
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi all,
I'm a little bit confused about the build errors reported by Intel's test bot and I'd really appreciate human input.
This is the first patch I submit, so apologies in advance if I missed a basic step.
I compiled and tested every patch before submission and they all compiled and worked on this tree:
git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git
After receiving this email, I followed the instructions attached to build it and indeed it failed.
However, I reverted my changes and the kernel still didn't compile.
Is this something I need to fix?
Thank you very much in advance,
José Expósito
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [kbuild-all] Re: [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-15 18:50 ` José Expósito
@ 2021-05-20 9:18 ` Rong Chen
2021-05-22 17:41 ` José Expósito
0 siblings, 1 reply; 10+ messages in thread
From: Rong Chen @ 2021-05-20 9:18 UTC (permalink / raw)
To: José Expósito
Cc: jikos, kbuild-all, benjamin.tissoires, linux-input, linux-kernel
On 5/16/21 2:50 AM, José Expósito wrote:
> On Wed, May 12, 2021 at 05:39:31PM +0800, kernel test robot wrote:
>> Hi "José,
>>
>> Thank you for the patch! Yet something to improve:
>>
>> [auto build test ERROR on hid/for-next]
>> [also build test ERROR on v5.13-rc1 next-20210511]
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://git-scm.com/docs/git-format-patch]
>>
>> url: https://github.com/0day-ci/linux/commits/Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
>> base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
>> config: s390-randconfig-r002-20210512 (attached as .config)
>> compiler: s390-linux-gcc (GCC) 9.3.0
>> reproduce (this is a W=1 build):
>> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # https://github.com/0day-ci/linux/commit/701f395a5566b6d2fd3a78389983237668902998
>> git remote add linux-review https://github.com/0day-ci/linux
>> git fetch --no-tags linux-review Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
>> git checkout 701f395a5566b6d2fd3a78389983237668902998
>> # save the attached .config to linux build tree
>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=s390
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> All errors (new ones prefixed by >>):
>>
>> s390-linux-ld: drivers/pcmcia/cistpl.o: in function `set_cis_map':
>> cistpl.c:(.text+0x3a2): undefined reference to `ioremap'
>> s390-linux-ld: cistpl.c:(.text+0x3dc): undefined reference to `iounmap'
>> s390-linux-ld: cistpl.c:(.text+0x404): undefined reference to `iounmap'
>> s390-linux-ld: cistpl.c:(.text+0x416): undefined reference to `ioremap'
>> s390-linux-ld: drivers/pcmcia/cistpl.o: in function `release_cis_mem':
>> cistpl.c:(.text+0xe16): undefined reference to `iounmap'
>> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_remove':
>> hid-magicmouse.c:(.text+0xd2c): undefined reference to `usb_kill_urb'
>>>> s390-linux-ld: hid-magicmouse.c:(.text+0xd48): undefined reference to `usb_free_coherent'
>>>> s390-linux-ld: hid-magicmouse.c:(.text+0xd54): undefined reference to `usb_free_urb'
>> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_battery_usb_urb_complete':
>> hid-magicmouse.c:(.text+0xe12): undefined reference to `usb_submit_urb'
>> s390-linux-ld: drivers/hid/hid-magicmouse.o: in function `magicmouse_probe':
>> hid-magicmouse.c:(.text+0x1194): undefined reference to `usb_alloc_urb'
>>>> s390-linux-ld: hid-magicmouse.c:(.text+0x121a): undefined reference to `usb_alloc_coherent'
>> s390-linux-ld: hid-magicmouse.c:(.text+0x1422): undefined reference to `usb_free_coherent'
>> s390-linux-ld: hid-magicmouse.c:(.text+0x142e): undefined reference to `usb_free_urb'
>>>> s390-linux-ld: hid-magicmouse.c:(.text+0x1462): undefined reference to `usb_submit_urb'
>> ---
>> 0-DAY CI Kernel Test Service, Intel Corporation
>> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> Hi all,
>
> I'm a little bit confused about the build errors reported by Intel's test bot and I'd really appreciate human input.
> This is the first patch I submit, so apologies in advance if I missed a basic step.
>
> I compiled and tested every patch before submission and they all compiled and worked on this tree:
> git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git
>
> After receiving this email, I followed the instructions attached to build it and indeed it failed.
> However, I reverted my changes and the kernel still didn't compile.
>
> Is this something I need to fix?
Hi José Expósito,
I think it's related to HAS_IOMEM in drivers/usb/Kconfig:
menuconfig USB_SUPPORT
bool "USB support"
depends on HAS_IOMEM
default y
help
This option adds core support for Universal Serial Bus (USB).
You will also need drivers from the following menu to make
use of it.
and I found a similar issue fixed by the below commit:
commit 1f685e6adbbe3c7b1bd9053be771b898d9efa655
Author: Randy Dunlap <rdunlap@infradead.org>
Date: Tue Jan 5 20:25:31 2021 -0800
ptp: ptp_ines: prevent build when HAS_IOMEM is not set
ptp_ines.c uses devm_platform_ioremap_resource(), which is only
built/available when CONFIG_HAS_IOMEM is enabled.
CONFIG_HAS_IOMEM is not enabled for arch/s390/, so builds on S390
have a build error:
s390-linux-ld: drivers/ptp/ptp_ines.o: in function
`ines_ptp_ctrl_probe':
ptp_ines.c:(.text+0x17e6): undefined reference to
`devm_platform_ioremap_resource'
Prevent builds of ptp_ines.c when HAS_IOMEM is not set.
Fixes: bad1eaa6ac31 ("ptp: Add a driver for InES time stamping IP
core.")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernel test robot <lkp@intel.com>
Link: lore.kernel.org/r/202101031125.ZEFCUiKi-lkp@intel.com
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link:
https://lore.kernel.org/r/20210106042531.1351-1-rdunlap@infradead.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index d2bf05ccbbe20d..f2edef0df40f5c 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -79,6 +79,7 @@ config DP83640_PHY
config PTP_1588_CLOCK_INES
tristate "ZHAW InES PTP time stamping IP core"
depends on NETWORK_PHY_TIMESTAMPING
+ depends on HAS_IOMEM
depends on PHYLIB
depends on PTP_1588_CLOCK
help
Best Regards,
Rong Chen
>
> Thank you very much in advance,
> José Expósito
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [kbuild-all] Re: [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-20 9:18 ` [kbuild-all] " Rong Chen
@ 2021-05-22 17:41 ` José Expósito
0 siblings, 0 replies; 10+ messages in thread
From: José Expósito @ 2021-05-22 17:41 UTC (permalink / raw)
To: Rong Chen
Cc: jikos, kbuild-all, benjamin.tissoires, linux-input, linux-kernel
On Thu, May 20, 2021 at 05:18:51PM +0800, Rong Chen wrote:
> Hi José Expósito,
>
> I think it's related to HAS_IOMEM in drivers/usb/Kconfig:
>
> menuconfig USB_SUPPORT
> bool "USB support"
> depends on HAS_IOMEM
> default y
> help
>
>
> This option adds core support for Universal Serial Bus (USB).
> You will also need drivers from the following menu to make use of
> it.
>
> and I found a similar issue fixed by the below commit:
>
> [...]
>
> Best Regards,
> Rong Chen
Hi Rong,
Thank you very much for taking the time to help me out with this issue, I really appreciate it.
As you mentioned, the issue was related with depends on in Kconfig, I'll email a new version of the patches.
Best regards,
Jose
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity
2021-05-11 18:20 ` [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
2021-05-12 9:39 ` kernel test robot
@ 2021-05-12 11:28 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-05-12 11:28 UTC (permalink / raw)
To: José Expósito, jikos
Cc: kbuild-all, benjamin.tissoires, linux-input, linux-kernel,
José Expósito
[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]
Hi "José,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hid/for-next]
[also build test ERROR on v5.13-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: csky-randconfig-r023-20210512 (attached as .config)
compiler: csky-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/701f395a5566b6d2fd3a78389983237668902998
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jos-Exp-sito/HID-magicmouse-register-power-supply/20210512-022327
git checkout 701f395a5566b6d2fd3a78389983237668902998
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=csky
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "usb_alloc_coherent" [drivers/hid/hid-magicmouse.ko] undefined!
>> ERROR: modpost: "usb_alloc_urb" [drivers/hid/hid-magicmouse.ko] undefined!
>> ERROR: modpost: "usb_submit_urb" [drivers/hid/hid-magicmouse.ko] undefined!
>> ERROR: modpost: "usb_free_urb" [drivers/hid/hid-magicmouse.ko] undefined!
>> ERROR: modpost: "usb_free_coherent" [drivers/hid/hid-magicmouse.ko] undefined!
>> ERROR: modpost: "usb_kill_urb" [drivers/hid/hid-magicmouse.ko] undefined!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28036 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/5] HID: magicmouse: Magic Mouse 2 USB battery capacity
2021-05-11 18:20 [PATCH 1/5] HID: magicmouse: register power supply José Expósito
2021-05-11 18:20 ` [PATCH 2/5] HID: magicmouse: report battery capacity over bluetooth José Expósito
2021-05-11 18:20 ` [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
@ 2021-05-11 18:20 ` José Expósito
2021-05-11 18:20 ` [PATCH 5/5] HID: magicmouse: report battery status José Expósito
3 siblings, 0 replies; 10+ messages in thread
From: José Expósito @ 2021-05-11 18:20 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, linux-input, linux-kernel, José Expósito
Report the battery capacity percentage for the Apple Magic Mouse 2
when it is connected over USB.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-magicmouse.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index ea8a85767c39..53e8a10f0551 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -911,8 +911,17 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev)
feature = feature_mt_trackpad2_usb;
}
} else if (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) {
- feature_size = sizeof(feature_mt_mouse2);
- feature = feature_mt_mouse2;
+ if (hdev->vendor == BT_VENDOR_ID_APPLE) {
+ feature_size = sizeof(feature_mt_mouse2);
+ feature = feature_mt_mouse2;
+ } else { /* USB_VENDOR_ID_APPLE */
+ /*
+ * The Magic Mouse 2 has the lightning connector on the
+ * bottom, making impossible to use it when it is
+ * charging.
+ */
+ return 0;
+ }
} else {
feature_size = sizeof(feature_mt);
feature = feature_mt;
@@ -947,7 +956,8 @@ static int magicmouse_probe(struct hid_device *hdev,
int ret;
if (id->vendor == USB_VENDOR_ID_APPLE &&
- id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
+ (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
+ id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) &&
hdev->type != HID_TYPE_USBMOUSE)
return 0;
@@ -1068,6 +1078,8 @@ static const struct hid_device_id magic_mice[] = {
USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE,
USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
+ USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE,
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] HID: magicmouse: report battery status
2021-05-11 18:20 [PATCH 1/5] HID: magicmouse: register power supply José Expósito
` (2 preceding siblings ...)
2021-05-11 18:20 ` [PATCH 4/5] HID: magicmouse: Magic Mouse " José Expósito
@ 2021-05-11 18:20 ` José Expósito
3 siblings, 0 replies; 10+ messages in thread
From: José Expósito @ 2021-05-11 18:20 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, linux-input, linux-kernel, José Expósito
Report the battery charging status for the Apple Magic Mouse 2
and the Apple Magic Trackpad 2.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-magicmouse.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 53e8a10f0551..4085b6698f2c 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -155,6 +155,7 @@ static enum power_supply_property magicmouse_ps_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_STATUS,
};
static bool magicmouse_can_report_battery(struct magicmouse_sc *msc)
@@ -229,6 +230,15 @@ static int magicmouse_battery_get_property(struct power_supply *psy,
val->intval = msc->battery.capacity;
break;
+ case POWER_SUPPLY_PROP_STATUS:
+ if (msc->input->id.vendor == BT_VENDOR_ID_APPLE) {
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+ } else { /* USB_VENDOR_ID_APPLE */
+ val->intval = (msc->battery.capacity == 100) ?
+ POWER_SUPPLY_STATUS_FULL :
+ POWER_SUPPLY_STATUS_CHARGING;
+ }
+ break;
default:
ret = -EINVAL;
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread