mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 22:55:53 -04:00
can: esd_usb: Replace initializer macros used for struct can_bittiming_const
Replace the macros used to initialize the members of struct can_bittiming_const with direct values. Then also use those struct members to do the calculations in esd_usb2_set_bittiming(). Link: https://lore.kernel.org/all/CAMZ6RqLaDNy-fZ2G0+QMhUEckkXLL+ZyELVSDFmqpd++aBzZQg@mail.gmail.com/ Suggested-by: Vincent MAILHOL <mailhol.vincent@wanadoo.fr> Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu> Link: https://lore.kernel.org/r/20230519195600.420644-3-frank.jungclaus@esd.eu [mkl: esd_usb2_set_bittiming() use esd_usb2_bittiming_const instead of priv->can.bittiming_const] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
1ad549cf98
commit
5a4dd8796d
@@ -60,18 +60,10 @@ MODULE_LICENSE("GPL v2");
|
||||
#define ESD_USB_NO_BAUDRATE GENMASK(30, 0) /* bit rate unconfigured */
|
||||
|
||||
/* bit timing CAN-USB/2 */
|
||||
#define ESD_USB2_TSEG1_MIN 1
|
||||
#define ESD_USB2_TSEG1_MAX 16
|
||||
#define ESD_USB2_TSEG1_SHIFT 16
|
||||
#define ESD_USB2_TSEG2_MIN 1
|
||||
#define ESD_USB2_TSEG2_MAX 8
|
||||
#define ESD_USB2_TSEG2_SHIFT 20
|
||||
#define ESD_USB2_SJW_MAX 4
|
||||
#define ESD_USB2_SJW_SHIFT 14
|
||||
#define ESD_USBM_SJW_SHIFT 24
|
||||
#define ESD_USB2_BRP_MIN 1
|
||||
#define ESD_USB2_BRP_MAX 1024
|
||||
#define ESD_USB2_BRP_INC 1
|
||||
#define ESD_USB2_3_SAMPLES BIT(23)
|
||||
|
||||
/* esd IDADD message */
|
||||
@@ -909,18 +901,19 @@ static const struct ethtool_ops esd_usb_ethtool_ops = {
|
||||
|
||||
static const struct can_bittiming_const esd_usb2_bittiming_const = {
|
||||
.name = "esd_usb2",
|
||||
.tseg1_min = ESD_USB2_TSEG1_MIN,
|
||||
.tseg1_max = ESD_USB2_TSEG1_MAX,
|
||||
.tseg2_min = ESD_USB2_TSEG2_MIN,
|
||||
.tseg2_max = ESD_USB2_TSEG2_MAX,
|
||||
.sjw_max = ESD_USB2_SJW_MAX,
|
||||
.brp_min = ESD_USB2_BRP_MIN,
|
||||
.brp_max = ESD_USB2_BRP_MAX,
|
||||
.brp_inc = ESD_USB2_BRP_INC,
|
||||
.tseg1_min = 1,
|
||||
.tseg1_max = 16,
|
||||
.tseg2_min = 1,
|
||||
.tseg2_max = 8,
|
||||
.sjw_max = 4,
|
||||
.brp_min = 1,
|
||||
.brp_max = 1024,
|
||||
.brp_inc = 1,
|
||||
};
|
||||
|
||||
static int esd_usb2_set_bittiming(struct net_device *netdev)
|
||||
{
|
||||
const struct can_bittiming_const *btc = &esd_usb2_bittiming_const;
|
||||
struct esd_usb_net_priv *priv = netdev_priv(netdev);
|
||||
struct can_bittiming *bt = &priv->can.bittiming;
|
||||
union esd_usb_msg *msg;
|
||||
@@ -932,7 +925,7 @@ static int esd_usb2_set_bittiming(struct net_device *netdev)
|
||||
if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
|
||||
canbtr |= ESD_USB_LOM;
|
||||
|
||||
canbtr |= (bt->brp - 1) & (ESD_USB2_BRP_MAX - 1);
|
||||
canbtr |= (bt->brp - 1) & (btc->brp_max - 1);
|
||||
|
||||
if (le16_to_cpu(priv->usb->udev->descriptor.idProduct) ==
|
||||
USB_CANUSBM_PRODUCT_ID)
|
||||
@@ -940,12 +933,12 @@ static int esd_usb2_set_bittiming(struct net_device *netdev)
|
||||
else
|
||||
sjw_shift = ESD_USB2_SJW_SHIFT;
|
||||
|
||||
canbtr |= ((bt->sjw - 1) & (ESD_USB2_SJW_MAX - 1))
|
||||
canbtr |= ((bt->sjw - 1) & (btc->sjw_max - 1))
|
||||
<< sjw_shift;
|
||||
canbtr |= ((bt->prop_seg + bt->phase_seg1 - 1)
|
||||
& (ESD_USB2_TSEG1_MAX - 1))
|
||||
& (btc->tseg1_max - 1))
|
||||
<< ESD_USB2_TSEG1_SHIFT;
|
||||
canbtr |= ((bt->phase_seg2 - 1) & (ESD_USB2_TSEG2_MAX - 1))
|
||||
canbtr |= ((bt->phase_seg2 - 1) & (btc->tseg2_max - 1))
|
||||
<< ESD_USB2_TSEG2_SHIFT;
|
||||
if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
|
||||
canbtr |= ESD_USB2_3_SAMPLES;
|
||||
|
||||
Reference in New Issue
Block a user